>>> db = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)>>> c = db.cursor()>>> c.execute('create table foo (bar integer, baz timestamp)')<sqlite3.Cursor object at 0x40fc50>>>> c.execute('insert into foo values(?, ?)', (23, datetime.datetime.now()))<sqlite3.Cursor object at 0x40fc50>>>> c.execute('select * from foo')<sqlite3.Cursor object at 0x40fc50>>>> c.fetchall()[(23, datetime.datetime(2009, 12, 1, 19, 31, 1, 40113))]
看到?int(对于声明为整数的列而言)和datetime(对于声明为timestamp的列而言)都将保留类型为原样的往返。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)