I check it every time I use it, so it's a memo memo. If you set row_factory of Connection to Row, you can access the result of query by column name.
sqlite.py
#!/usr/bin/env python
import sqlite3
con = sqlite3.connect(":memory:")
con.executescript("""
create table temp (hoge text);
insert into temp values ('piyo');
insert into temp values ('fuga');
""")
con.commit()
con.row_factory = sqlite3.Row
cur = con.execute("""
select * from temp
""")
for c in cur:
print c["hoge"]
Recommended Posts