| 1 | import sqlite3 |
| 2 | |
| 3 | con = sqlite3.connect(":memory:") |
| 4 | cur = con.cursor() |
| 5 | cur.execute("create table people (name_last, age)") |
| 6 | |
| 7 | who = "Yeltsin" |
| 8 | age = 72 |
| 9 | |
| 10 | # This is the qmark style: |
| 11 | cur.execute("insert into people values (?, ?)", (who, age)) |
| 12 | |
| 13 | # And this is the named style: |
| 14 | cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) |
| 15 | |
| 16 | print cur.fetchone() |