Re: A real bug!
Al Niessner <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <1244670965.4273.101.camel@charon> |
Thanks. I use the Ubuntu apt-get package. I used: d = datetime.fromtimestamp (ts) return psycopg2.Timestamp (d.year, d.month, ...) Works well enough for me. At some point I can figure out how to do UTC this way too. On Wed, 2009-06-10 at 23:28 +0200, Federico Di Gregorio wrote: > Il giorno mer, 10/06/2009 alle 11.57 -0700, Al Niessner ha scritto: > > So, I am now running with psycopg2 and am doing a full load of my > > database and am getting this error: > > > > dbapi.TimestampFromTicks (timestamp) > > ValueError: second must be in 0..59 > > > > So, I have gone back and am testing with just importing os and > > psycopg2 > > and it fails just the same. > > > > >>> import os > > >>> import psycopg2 > > >>> os.path.getatime (fn) > > 1241706839.5885506 > > >>> psycopg2.TimeFromTicks (os.path.getatime (fn)) > > --------------------------------------------------------------------------- > > ValueError Traceback (most recent call > > last) > > ValueError: second must be in 0..59 > > > > So, here is where I am confused as whose bug it is. If psycopg cares > > about rounding at seconds for ticks where the rest of python does not, > > should it not round rather than make me do it? In other words, psycopg > > is massaging the ticks to a timestamp that postgresql will accept so > > it > > should do the rounding and hide the details of postgresql's needs from > > me. Of course, someone will cry that the timestamp does not match > > their > > ticks. Damned if you do and damned if you do not. > > > > If you want to test, you can always do: > > psycopg2.TimeFromTicks (1241706839.5885506) > > This seems to be a real bug. ;) I don't have the time to test the > obvious fix but if you build from source you can try to modify the file > psycopg/adapter_datetime.c around line 396. Change the line: > > t = (time_t)round(ticks); > > to > > t = (time_t)floor(ticks); > > and recompile. > > Good luck, > federico > > _______________________________________________ > Psycopg mailing list > Psycopg-IAPFreCvJWPBWskQ1e/[email protected] > http://lists.initd.org/mailman/listinfo/psycopg -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers