[DB-SIG] checking column types from cursor object in a database-independent way?
Dan Lenski
dlenski at gmail.com
Mon Apr 22 18:40:09 CEST 2013
Vernon D. Cole <vernondcole <at> gmail.com> writes:
> Dan:
> You have a very good point. Perhaps we should put that on the wish list for
API version 3.
> The .connection attribute of the cursor is optional. IMHO it should be
required.. I think most existing api packages implement it.
> The it is suggested, but not required by the PEP, that the exception classes
"should be
> exposed on the Connection objects as attributes (in addition to
> being available at module scope)." Adding them to the class definition for
Connection is not difficult, and is quite convenient to use. I don't like the
extra symbols in my debugger, but I can live with it. It would be trivial to
include the type objects and constructors there, too. Again, perhaps this
should be required.
Great, I do think it'd be a useful feature for v3!
I don't know enough about the design goals of DBAPI to say whether the
connection object is the *right* place to expose the column type objects, but
it does seem like that would be a straightforward solution to the problem, as
long as .connection is guaranteed to exist.
if cur.description[n][1] == cur.connection.STRING:
pass
More information about the DB-SIG
mailing list