Python code coverage for Doc/includes/sqlite3/adapter_point_2.py
# | count | content |
---|---|---|
1 | n/a | import sqlite3 |
2 | n/a | |
3 | n/a | class Point: |
4 | n/a | def __init__(self, x, y): |
5 | n/a | self.x, self.y = x, y |
6 | n/a | |
7 | n/a | def adapt_point(point): |
8 | n/a | return "%f;%f" % (point.x, point.y) |
9 | n/a | |
10 | n/a | sqlite3.register_adapter(Point, adapt_point) |
11 | n/a | |
12 | n/a | con = sqlite3.connect(":memory:") |
13 | n/a | cur = con.cursor() |
14 | n/a | |
15 | n/a | p = Point(4.0, -3.2) |
16 | n/a | cur.execute("select ?", (p,)) |
17 | n/a | print(cur.fetchone()[0]) |