comparison Doc/lib/sqlite3/execsql_fetchonerow.py @ 38069:cf19a123a5d9 legacy-trunk

Further integration of the documentation for the sqlite3 module. There's still quite some content to move over from the pysqlite manual, but it's a start now.
author Gerhard Häring <gh@ghaering.de>
date Mon, 01 May 2006 15:14:48 +0000
parents
children 204ec383b445
comparison
equal deleted inserted replaced
38068:ca6c91531a96 38069:cf19a123a5d9
1 import sqlite3
2
3 con = sqlite3.connect("mydb")
4
5 cur = con.cursor()
6 SELECT = "select name_last, age from people order by age, name_last"
7
8 # 1. Iterate over the rows available from the cursor, unpacking the
9 # resulting sequences to yield their elements (name_last, age):
10 cur.execute(SELECT)
11 for (name_last, age) in cur:
12 print '%s is %d years old.' % (name_last, age)
13
14 # 2. Equivalently:
15 cur.execute(SELECT)
16 for row in cur:
17 print '%s is %d years old.' % (row[0], row[1])