shithub: riscv

ref: 6280c0f17bf3919cf6c2506fec6edfa0a7ec10fe
dir: /sys/src/cmd/python/Doc/lib/sqlite3/adapter_datetime.py/

View raw version
import sqlite3
import datetime, time

def adapt_datetime(ts):
    return time.mktime(ts.timetuple())

sqlite3.register_adapter(datetime.datetime, adapt_datetime)

con = sqlite3.connect(":memory:")
cur = con.cursor()

now = datetime.datetime.now()
cur.execute("select ?", (now,))
print cur.fetchone()[0]