Python code coverage for Doc/includes/sqlite3/row_factory.py
# | count | content |
---|---|---|
1 | n/a | import sqlite3 |
2 | n/a | |
3 | n/a | def dict_factory(cursor, row): |
4 | n/a | d = {} |
5 | n/a | for idx, col in enumerate(cursor.description): |
6 | n/a | d[col[0]] = row[idx] |
7 | n/a | return d |
8 | n/a | |
9 | n/a | con = sqlite3.connect(":memory:") |
10 | n/a | con.row_factory = dict_factory |
11 | n/a | cur = con.cursor() |
12 | n/a | cur.execute("select 1 as a") |
13 | n/a | print(cur.fetchone()["a"]) |