cpython/Doc/includes/sqlite3/rowclass.py

13 lines
299 B
Python
Raw Normal View History

2007-08-15 11:28:22 -03:00
import sqlite3
con = sqlite3.connect(":memory:")
2007-08-15 11:28:22 -03:00
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute("select 'John' as name, 42 as age")
2007-08-15 11:28:22 -03:00
for row in cur:
assert row[0] == row["name"]
assert row["name"] == row["nAmE"]
2007-08-15 11:28:22 -03:00
assert row[1] == row["age"]
assert row[1] == row["AgE"]