2 ms·
Honestly, the "proper" way should be passing something like this def namedtuple_factory(cursor, row): fields = [column[0] for column in cursor.desc
by Joker_vD 2y ago
Honestly, the "proper" way should be passing something like this
def namedtuple_factory(cursor, row):
fields = [column[0] for column in cursor.description]
cls = namedtuple("Row", fields)
return cls._make(row)
to the fetchall(), to automatically keep the names in sync with those in the SQL query string.
- ttyprintk 2y agoImplemented as conn.row_factory = sqlite3.Row