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

Michael Bayer <[email protected]>
Newsgroups gmane.comp.python.db
Message-ID <[email protected]>
On Apr 21, 2013, at 9:39 PM, Daniel Lenski <[email protected]> wrote:

> 
> I *could* pass around a handle to the DB module along with the cursor
> itself, as you've suggested, but that seems redundant and error-prone
> to me.  To my mind, this is a small gap in the DBAPI design:
>  (1) DBAPI does specify a set of module-dependent type objects
> against which column type objects are to be compared
>  (2) DBAPI does specify a cursor object which will produce column
> type objects after a query is executed
>  (3) DBAPI *doesn't* provide any way to get from the cursor object to
> the module-defined type objects, at least not without passing  around
> module-dependent object.


IMHO, the DBAPI is not meant to be used as a direct API within higher level application code; it only aims to provide a consistent low-level API to a wide variety of databases.   It should always be framed within some kind of abstraction layer within real-world application.  Therefore it should not concern/complicate itself worrying about convenience accessors, this only makes it more difficult for DBAPI implementors, leads to greater inconsistency between implementations, and makes it harder to test for compliance.




_______________________________________________
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.