[DB-SIG] Python/PDO field types

Bryan J Gudorf bgudorf at neurokode.com
Wed Dec 17 16:31:20 EST 2003


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

-----Original Message-----
From: db-sig-bounces at python.org [mailto:db-sig-bounces at python.org]On
Behalf Of Andy Todd
Sent: Wednesday, December 17, 2003 4:10 PM
To: Derek Croxton
Cc: db-sig at python.org
Subject: Re: [DB-SIG] Python/PDO field types


Derek Croxton wrote:
> I've been using PDO successfully, but I can't figure out what the
> type_id of a field object means.  Type_id returns a number that
> corresponds to a data type, but I can't find any mapping of numbers to
> types.  The help note in PDO says "see the DB-API docs," so I found what
> I appears to be the correct page at
> http://www.python.org/peps/pep-0249.html.  However, here I can find only
> a list of types under "Type Objects and Constructors" -- there is no
> mention of which number corresponds to which type.  I figure there must
> be such a list somewhere (whether part of the Python DB API or of PDO I
> don't know), so I would appreciate it if someone could direct me to it.
>
> Thanks,
> Derek Croxton
>

As far as I can tell PDO passes on whatever it gets from the cursor
description. This is supplied by the underlying DB-API module you use.
If its MySQLdb then the answer is in the documentation;

"""
DATA
     BINARY = DBAPISet(252, 251, 250, 249)
     DATE = DBAPISet(10, 14)
     NULL = 'NULL'
     NUMBER = DBAPISet(0, 5, 4, 9, 3, 8, 1, 13)
     ROWID = DBAPISet()
     STRING = DBAPISet(1, 247, 254, 253)
     TIME = DBAPISet(11,)
     TIMESTAMP = DBAPISet(7, 12)
"""

I got this by typing help("MySQLdb") at the Python prompt (after
importing MySQLdb). If you are connecting to a different type of
database then look at the documentation for the db module.

I'm running MySQL 4.0.16, MySQLdb 0.9.2 and Python 2.3.2

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


_______________________________________________
DB-SIG maillist  -  DB-SIG at python.org
http://mail.python.org/mailman/listinfo/db-sig




More information about the DB-SIG mailing list