Yes, this project is probably worth it. However at the moment I am looking 
to use my already implemented daterange logic instead of exploring a new 
library and having to refactor my codebase for it

Getting closer with this, adaptation is failing:

class MyDateRange_(DATERANGE, DateRange):
  pass
class MyDateRange(TypeDecorator):
  impl = MyDateRange_



On Friday, April 24, 2015 at 3:11:36 PM UTC+2, Richard Kuesters wrote:
>
>  perhaps this could help you?
>
>
> http://sqlalchemy-utils.readthedocs.org/en/latest/range_data_types.html#datetimerangetype
>
>
> richard.
>
>
> On 04/24/2015 10:09 AM, Dimitris Theodorou wrote:
>  
> Hi,
>
> I am using psycopg2 and trying to put together a new daterange type that 
> combines the following:
>
> 1. A custom daterange class which provides various useful helpers 
> (backwards/forwards iteration, intersection).
> 2. The psycopg2 DateRange that fills in with some helpers of its own 
> (contains, comparisons) and takes care of marshaling the object from/to the 
> db
> 3. The DATERANGE sqlalchemy/postgres type to take care of emiting of SQL 
> operators and DDL, and so that I can use it both when querying and when 
> declaring Columns()
>
> So my naive approach is the following, going by the guideline at 
> http://docs.sqlalchemy.org/en/latest/core/compiler.html#subclassing-guidelines
> :
>
>  from psycopg2.extras import DateRange
> from sqlalchemy.dialects.postgresql import DATERANGE
>
> class MyDateRange(TypeDecorator, DateRange):
>
>   impl = DATERANGE
>
>   def intersection():
>       #...
>  
>
> This crashes when emitting a table.create() statement.
>
> When I look at the documentation on how to create/modify types I am left 
> dumfounded and I realize I would need a significant trial and error 
> investment to figure out how things work. Does anyone else have experience 
> with such an attempt? I'd rather not  become an expert in sqlalchemy type 
> extension before I can make this work.
>
> Thanks,
> Dimitris
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to