blob: d670700f0491b176b76de9d34dedb3e879db3781 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001import sqlite3
2
Éric Araujo28053fb2010-11-22 03:09:19 +00003class Point:
Georg Brandl116aa622007-08-15 14:28:22 +00004 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])