mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
sqlite3: Port relevant documentation changes from 3.2
Initial patch by Johannes Vogel. Issue #13491.
This commit is contained in:
parent
c56bca31e9
commit
a15a8d2a0c
8 changed files with 36 additions and 48 deletions
|
@ -1,11 +1,16 @@
|
|||
import sqlite3
|
||||
|
||||
con = sqlite3.connect("mydb")
|
||||
|
||||
con = sqlite3.connect(":memory:")
|
||||
cur = con.cursor()
|
||||
cur.execute("create table people (name_last, age)")
|
||||
|
||||
who = "Yeltsin"
|
||||
age = 72
|
||||
|
||||
cur.execute("select name_last, age from people where name_last=? and age=?", (who, age))
|
||||
# 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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue