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