• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import sqlite3
2
3def dict_factory(cursor, row):
4    d = {}
5    for idx, col in enumerate(cursor.description):
6        d[col[0]] = row[idx]
7    return d
8
9con = sqlite3.connect(":memory:")
10con.row_factory = dict_factory
11cur = con.cursor()
12cur.execute("select 1 as a")
13print(cur.fetchone()["a"])
14
15con.close()
16