PageRenderTime 33ms CodeModel.GetById 24ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/Doc/includes/sqlite3/adapter_point_1.py

http://unladen-swallow.googlecode.com/
Python | 16 lines | 12 code | 4 blank | 0 comment | 1 complexity | bb7c68aead6dfbc28f2279d19a387d3c MD5 | raw file
 1import sqlite3
 2
 3class Point(object):
 4    def __init__(self, x, y):
 5        self.x, self.y = x, y
 6
 7    def __conform__(self, protocol):
 8        if protocol is sqlite3.PrepareProtocol:
 9            return "%f;%f" % (self.x, self.y)
10
11con = sqlite3.connect(":memory:")
12cur = con.cursor()
13
14p = Point(4.0, -3.2)
15cur.execute("select ?", (p,))
16print cur.fetchone()[0]