[DB-SIG] checking column types from cursor object in a database-independent way?

Michael Bayer mike_mp at zzzcomputing.com
Mon Apr 22 16:24:54 CEST 2013

On Apr 21, 2013, at 9:39 PM, Daniel Lenski <dlenski at gmail.com> 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.

More information about the DB-SIG mailing list