Incomplete description using sqlite3

Sibylle Koczian nulla.epistola at web.de
Tue Nov 7 10:56:14 EST 2017


Am 06.11.2017 um 23:40 schrieb Skip Montanaro:
> 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
> 

I'd suspect the explanation is here:
https://sqlite.org/datatype3.html

HTH
Sibylle




More information about the Python-list mailing list