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

« back to all changes in this revision

Viewing changes to Doc/includes/sqlite3/adapter_point_2.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
class Point(object):
 
4
    def __init__(self, x, y):
 
5
        self.x, self.y = x, y
 
6
 
 
7
def adapt_point(point):
 
8
    return "%f;%f" % (point.x, point.y)
 
9
 
 
10
sqlite3.register_adapter(Point, adapt_point)
 
11
 
 
12
con = sqlite3.connect(":memory:")
 
13
cur = con.cursor()
 
14
 
 
15
p = Point(4.0, -3.2)
 
16
cur.execute("select ?", (p,))
 
17
print cur.fetchone()[0]