Column types with DB API

T

Thomas Robitaille

Hi,

I'm trying to use DB API compliant database modules
(psycopg2,MySQLdb,SQLite) to access SQL databases, and I am trying to
determine the type of each column in a table. The DB API defines
cursor.description which contains information about the column names and
types (once .execute() has been used to select part or all of the table),
but the types are expressed as integers. I realize that these numbers can be
checked against the type objects such as MySQLdb.NUMBER to determine whether
a given column is a number, a date, text, etc. However, is there any way to
determine what the sub-type of a column is, for example if a column is a
NUMBER, is there a way to determine if it is a 2, 4, or 8-byte integer or
real number?

Thanks in advance for any advice,

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top