Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | import sqlite3 |
2 | |||||
Éric Araujo | 28053fb | 2010-11-22 03:09:19 +0000 | [diff] [blame] | 3 | class Point: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 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]) |