[DB-SIG] Python/PDO field types

Andy Todd andy47 at halfcooked.com
Thu Dec 18 05:35:08 EST 2003


Bryan J Gudorf wrote:
> Andy, Derek,
> 	This is correct. PDO does pass on the type_code it gets from .description.
> Although these types are specified in the DB-API, you may need to check with
> your
> module documentation on how to use them.
> 
> Bryan J Gudorf
> ~NeuroKode Labs, LLC
> 
[snip]

Whilst the DB-API specifies that you should have these types, it doesn't 
specify (probably quite rightly) how you should implement them. Which 
can be confusing. I think what PDO is doing is correct, but just wanted 
to point out that what is returned as a column type is down to the DB 
module and their implementations can vary.

For instance, MySQLdb (as previously mentioned) uses the 
MySQLdb.constants.FIELD_TYPE module to identify the type of columns in a 
   cursor (which are a series of numbers mapped to descriptions).

Contrast that with cx_Oracle which has a number of type objects (BINARY, 
DATETIME, NUMBER, STRING, etc.) which are used to categorise the columns 
returned from an execute and will be in the description attribute of 
your cursor.

Regards,
Andy
-- 
--------------------------------------------------------------------------------
 From the desk of Andrew J Todd esq - http://www.halfcooked.com/



More information about the DB-SIG mailing list