~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Doc/includes/sqlite3/execute_1.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import sqlite3
2
2
 
3
 
con = sqlite3.connect("mydb")
4
 
 
 
3
con = sqlite3.connect(":memory:")
5
4
cur = con.cursor()
 
5
cur.execute("create table people (name_last, age)")
6
6
 
7
7
who = "Yeltsin"
8
8
age = 72
9
9
 
10
 
cur.execute("select name_last, age from people where name_last=? and age=?", (who, age))
 
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
 
11
16
print(cur.fetchone())