History

add hg and python

cinap_lenrek committed 15 years ago

Commit 4bb9e221 parent 987265c3706 files · +1228772 −-233Browse files

Showing the changes to sys/src/cmd/python/Doc/lib/sqlite3/execsql_fetchonerow.py (1 of 3706 files). Show all

Unified · Split

sys/src/cmd/python/Doc/lib/sqlite3/execsql_fetchonerow.py+17−0
@@ -0,0 +1,17 @@
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])