* Andreas Jung <[EMAIL PROTECTED]> [070423 09:49]:
> 
> 
> --On 23. April 2007 08:18:54 +0200 Andreas Jung <[EMAIL PROTECTED]> wrote:
> 
> >Additional info: using SA 0.3.6, Postgres 7.4.6, psycopg 2.0.4
> >
> >Andreas
> >
> >>  File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 971,
> >>in fetchall
> >>ValueError: second must be in 0..59
> >>
> >>Any idea where this is coming from?
> >>
> 
> This issue is caused by a TIMESTAMP column within our database with NULL
> values. psycopg2 tried to convert them to Python datetime instances which
> fails of course...any idea how to get around this issue on the SA level?

Well, psycopg2 handles that case well enough:

>>> x.fetchall()
[(datetime.datetime(2007, 4, 5, 14, 55, 55),)]
>>> x.execute("SELECT NULL::timestamp;")
>>> x.fetchall()
[(None,)]
>>> x.execute("SELECT '2007-04-05 14:55:55'::timestamp;")
>>> x.fetchall()
[(datetime.datetime(2007, 4, 5, 14, 55, 55),)]
>>> psycopg2.__version__
'2.0.5.1 (dec dt ext pq3)'

What I've found in this case, it makes sense to activate SQL logging,
and take a hard look at the data.

E.g. I once had somebody enter a date like 04/01/200038. PostgreSQL
(and the app that inserted it used manually constructed sql) accepted
that timestamp. The sqlalch app trying to read that timestamp crashed,
because datetime objects have a smaller dynamic range than timestamp
in PostgreSQL.

But that wouldn't apply to seconds. Only way to be sure is to capture
the SQL statement fetching the data, and fetch it manually with psql
to see what is SO special about the data?

Andreas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to