[DB-SIG] Python/PDO field types
Andy Todd
andy47 at halfcooked.com
Wed Dec 17 16:10:01 EST 2003
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/
More information about the DB-SIG
mailing list