[DB-SIG] WHat's the status of DB modules and datetime.py supp ort?
jfranz at neurokode.com
Mon Jan 5 09:18:58 EST 2004
>e) Add an interface for mapping from type_id's to type classes (i.e., the
> reverse of the mapping provided by type objects).
Wouldn't the system I sugested saturday be just that?
Perhaps my message was too politcal for the actual technical sugestions to
get noticed - or the weekend timing.
>From said message: (verbose, I know)
"Perhaps, instead, due to speed issues, memory issues, and implementation
issues of keeping the results in a python-object form, the types defined as
allowable for such a field (type_code) should (at the least):
a) Be defined within the standard
b) be represented within the field by a reference to a class within the
module that is a 'wrapper' for that type. This type-class should provide a
standard interface (varying based upon the underlying type), limited of
course by the precision of the underlying DB. The interfaces should be
defined within the standard.
- These classes should allow for instance creation from an output column
of that type.
- These type classes should be the same as the types used for insertion,
or at least provide interfaces so that they _work_ for insertion and hide
the details from the user.
If actual results are _not_ going to be returned as objects suitable for
insertion (memory concerns, overhead concerns, ease of use of values via
native python types), then the above would at least allow for easy
conversion of a value into insertable form without the type of the column
needing to be explicitly known, as such:
type_code = 1 # see pep 249
curs.execute("INSERT into test VALUES (%s)", (module.DateFromTicks(x),))
curs.execute("SELECT datefiled from test")
d = curs.fetchone()
curs.execute("INSERT into test VALUES(%s)", (curs.description(d),))
Of course, that's rather hard to read, so perhaps a utility function to
utilize said .description field should be made, thus we get:
curs.execute("INSERT into test VALUES(%s)", (curs.convertforinput(, d),))
Of course, taking it further and making it so that columns of the same type
DBs can be passed around and cross inserted sounds nice. +1 for
More information about the DB-SIG