source: python/trunk/Doc/includes/sqlite3/execsql_fetchonerow.py

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 475 bytes
Line 
1import sqlite3
2
3con = sqlite3.connect("mydb")
4
5cur = con.cursor()
6SELECT = "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):
10cur.execute(SELECT)
11for (name_last, age) in cur:
12 print '%s is %d years old.' % (name_last, age)
13
14# 2. Equivalently:
15cur.execute(SELECT)
16for row in cur:
17 print '%s is %d years old.' % (row[0], row[1])
Note: See TracBrowser for help on using the repository browser.