~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import sqlite3
 
2
 
 
3
def dict_factory(cursor, row):
 
4
    d = {}
 
5
    for idx, col in enumerate(cursor.description):
 
6
        d[col[0]] = row[idx]
 
7
    return d
 
8
 
 
9
con = sqlite3.connect(":memory:")
 
10
con.row_factory = dict_factory
 
11
cur = con.cursor()
 
12
cur.execute("select 1 as a")
 
13
print cur.fetchone()["a"]