This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: sqlite3 Cursor.description can't return column types
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
Status: closed Resolution: duplicate
Dependencies: Superseder: sqlite3 Cursor.description doesn't set type_code
View: 11691
Assigned To: Nosy List: ZackerySpytz, berker.peksag, ghaering, kyoshidajp, lemburg
Priority: normal Keywords:

Created on 2017-11-20 13:08 by kyoshidajp, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg306539 - (view) Author: Katsuhiko YOSHIDA (kyoshidajp) * Date: 2017-11-20 13:08
My schema of sqlite3 table is the following.

--- schema check start ---
% sqlite3 sample.db
SQLite version 3.16.0 2016-11-04 19:09:39
Enter ".help" for usage hints.
sqlite> PRAGMA table_info(Employees);


--- schema check end ---

Then, I tried to output column types by calling Cursor.description. Like this.

--- sample code start ---
import sqlite3

con = sqlite3.connect("sample.db", detect_types=sqlite3.PARSE_DECLTYPES)
cursor = con.cursor()
cursor.execute("select LastName, FirstName from Employees limit 1;")
print cursor.description
--- sample code end ---

The output is the following.

(('LastName', None, None, None, None, None, None), ('FirstName', None, None, None, None, None, None))

When changing detect_types parameter to


the result is same.

I expect to output a column type in second element. Could you tell me why?
msg306541 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-11-20 13:55
Thank you for your report. According to we always set the 'type_code' field described in PEP 249 to None. Setting it would be a new feature so it can only go into Python 3.7.
msg322421 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-07-26 13:35
This seems to be a duplicate of #11691.
msg322432 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-07-26 14:25
Good catch, Zackery, thanks! This is indeed a duplicate of issue 11691.
Date User Action Args
2022-04-11 14:58:54adminsetgithub: 76264
2018-07-26 14:25:51berker.peksagsetstatus: open -> closed
superseder: sqlite3 Cursor.description doesn't set type_code
messages: + msg322432

resolution: duplicate
stage: needs patch -> resolved
2018-07-26 13:35:28ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg322421
2017-11-20 13:55:03berker.peksagsetversions: + Python 3.7, - Python 2.7, Python 3.6
nosy: + ghaering, berker.peksag, lemburg

messages: + msg306541

type: behavior -> enhancement
stage: needs patch
2017-11-20 13:08:43kyoshidajpcreate