A real bug!

Al Niessner <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <1244660278.4273.78.camel@charon>
Well, maybe.

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)

and if you want to see what it is:
>>> datetime.datetime.fromtimestamp (os.path.getatime (fn))
datetime.datetime(2009, 5, 7, 7, 33, 59, 588551)

Anyway, I am going to put some code in to round and then call it good.
Just thought you may all want to know.

-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.