source: trunk/essentials/dev-lang/python/Doc/lib/sqlite3/adapter_point_2.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 338 bytes
Line 
1import sqlite3
2
3class Point(object):
4 def __init__(self, x, y):
5 self.x, self.y = x, y
6
7def adapt_point(point):
8 return "%f;%f" % (point.x, point.y)
9
10sqlite3.register_adapter(Point, adapt_point)
11
12con = sqlite3.connect(":memory:")
13cur = con.cursor()
14
15p = Point(4.0, -3.2)
16cur.execute("select ?", (p,))
17print cur.fetchone()[0]
Note: See TracBrowser for help on using the repository browser.