|
From: Brandon C. R. <bra...@oi...> - 2004-08-24 15:10:25
|
The Python DB-API 2.0 describes the following function and type:
Date(year,month,day)
This function constructs an object holding a date value.
DATETIME
This type object is used to describe date/time columns in
a database.
If one naively assumes that the Date(...) function will return
instances of the type DATETIME, then one will be disappointed by
psycopg - the function yields values of <type 'datetime'> instead.
More surprising is that psycopg actually seems to violate the standard
by not using not using the type DATETIME when returning timestamps
from database tables; selecting a value of SQL type TIMESTAMP from a
table returns a full-fledged DateTime object:
>>> d
<DateTime object for '2003-12-17 00:00:00.00' at 401dce58>
>>> type(d)
<type 'DateTime'>
where 'DateTime' comes from the mx.DateTime module. In order to make
psycopg consistent, I suggest:
- That psycopg.DATETIME, rather than being an apparently unused
type, become a reference to the mx.DateTime.DateTime type that
psycopg is actually using to return dates. I believe that this
change is necessary to bring this aspect of psycopg into
conformance with the DB-API.
- That the psycopg.Date(...) and other time construction functions
return DateTime instances so they can be most easily compared
with dates and times returned by queries.
I am perfectly willing to jump over to the devel list and do this
coding myself; but I wanted to ask here first in case I'm
misunderstanding something.
Thanks,
--
Brandon Craig Rhodes http://www.rhodesmill.org/brandon
Georgia Tech br...@oi...
|