On Dec 23, 2013, at 9:29 AM, Sibylle Koczian <[email protected]> wrote:

> Am 21.12.2013 16:27, schrieb Michael Bayer:
>> In the case of using Postgresql, the type
>> sqlalchemy.dialects.postgresql.INTERVAL takes over wherever you might
>> have used a sqlalchemy.Interval type.    In this case, psycopg2 is
>> what’s doing whatever conversions are occurring here - if a result
>> row type has the Postgres OID for an “INTERVAL”, psycopg2 jumps in
>> and does the conversion to timedelta.  This isn’t on the SQLAlchemy
>> side.   If psycopg2 is doing the wrong thing you might want to look
>> over on their side for updates or bug reports.
>> 
> I don't really know if psycopg2 is doing the wrong thing. Py-postgresql does 
> the same conversion. This might be viewed as a problem with 
> datetime.timedelta which isn't suitable for intervals of several months.

maybe you want to check on that because I’m not familiar with any such 
limitation in datetime.timedelta, it essentially stores a number of days.   
Below is an example using timedeltas of twelve years, eight months, and four 
days:

>>> import datetime
>>> datetime.datetime(1992, 12, 19) - datetime.datetime(1980, 4, 15)
datetime.timedelta(4631)
>>> d1 = datetime.datetime(1992, 12, 19) - datetime.datetime(1980, 4, 15)
>>> datetime.datetime(1992, 12, 19) + d1
datetime.datetime(2005, 8, 24, 0, 0)




Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to