Reputation: 63192
I am using the sqlite
connector and examining the cursor
returned from a query
:
curs = s.conn.cursor()
curs.execute("select count(distinct category) as ncats from part")
rows = curs.fetchall()
Examining the curs.description()
in the debugger we see it is a 7-tuple of the single column ncats
plus 6 None
s.
print(f'cursor description type: {type(curs.description)}
len: {len(curs.description[0])}')
cursor description type: <class 'tuple'> len: 7
Well the more the merrier ?? What are these for - and should we expect there to always be six extra participants in the results?
Upvotes: 1
Views: 844
Reputation: 52549
From the documentation:
description
This read-only attribute provides the column names of the last query. To remain compatible with the Python DB API, it returns a 7-tuple for each column where the last six items of each tuple are None.
From the DB API documentation:
Each of these sequences contains information describing one result column:
- name
- type_code
- display_size
- internal_size
- precision
- scale
- null_ok
The first two items (name and type_code) are mandatory, the other five are optional and are set to None if no meaningful values can be provided.
name
is the only one of those that makes sense given sqlite's type system.
Upvotes: 1