sqlite_test.py

来自「Harvestman-最新版本」· Python 代码 · 共 29 行

PY
29
字号
import sqlite3class Point(object):    def __init__(self, x, y):        self.x, self.y = x, y    def __conform__(self, protocol):        if protocol is sqlite3.PrepareProtocol:            return '%f;%f' % (self.x, self.y)con = sqlite3.connect("test")c = con.cursor()p = Point(5.0, 3.5)c.execute("drop table points")c.execute("create table points (point text)")#cur.execute("select ?", (p,))#print cur.fetchone()[0]c.execute("insert into points values (?)", (p,))c.execute("select * from points")print c.fetchall()c.close()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?