source: trunk/essentials/dev-lang/python/Doc/lib/sqlite3/row_factory.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 291 bytes
Line 
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"]
Note: See TracBrowser for help on using the repository browser.