mirror of
https://github.com/python/cpython.git
synced 2025-09-17 06:06:25 +00:00
Further integration of the documentation for the sqlite3 module. There's still
quite some content to move over from the pysqlite manual, but it's a start now.
This commit is contained in:
parent
e3c958c33b
commit
82560ebb8d
30 changed files with 654 additions and 3 deletions
14
Doc/lib/sqlite3/adapter_datetime.py
Normal file
14
Doc/lib/sqlite3/adapter_datetime.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
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]
|
Loading…
Add table
Add a link
Reference in a new issue