Incomplete description using sqlite3

Skip Montanaro skip.montanaro at gmail.com
Mon Nov 6 17:40:09 EST 2017


I'm using sqlite3 (2.6.0, SQLite version 3.13.0, Python 2.7.13) and
was hoping to introspect the types of a table using the cursor's
description attribute. PEP 249 states: "The first two items (name and
type_code) are mandatory..." I tried this query:

conn = sqlite3("/some/existing/database")
curs = conn.cursor()
curs.execute("select * from mytable limit 1")
curs.fetchall()

Looking at curs.description, I see that it contained a seven-element
tuple for each column, but only the first element (name) was non-None.
Even the type_code field (required, according to the PEP) was None. I
tried the same trick using pyodbc talking to SQL Server (select top(1)
* from mytable). It returned more useful information.

Did I go about things wrong with SQLite, or is the sqlite3 module (or
SQLite database underlying it) not capable enough?

Thx,

Skip



More information about the Python-list mailing list