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:

|
|
|frompsycopg2.extras importDateRange
fromsqlalchemy.dialects.postgresql importDATERANGE

classMyDateRange(TypeDecorator,DateRange):

  impl =DATERANGE

defintersection():
#...
|
|


|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+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
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.

<<attachment: richard.vcf>>

Reply via email to