You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
399 B
19 lines
399 B
7 months ago
|
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())
|
||
|
|
||
|
con.close()
|