Re: checking column types from cursor object in a database-independent way?

Dan Lenski <[email protected]>
Newsgroups gmane.comp.python.db
Message-ID <[email protected]>
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



_______________________________________________
DB-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/db-sig
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.