summaryrefslogtreecommitdiff
path: root/doc/includes/sqlite3/adapter_datetime.py
blob: 5a43b02f77fa2229e08863c6b743b59504274c3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from pysqlite2 import dbapi2 as 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]