Страница 1 из 1

time

Добавлено: Чт, 16 февраля 2017, 07:29:45
dyvniy

Добавлено: Пн, 27 февраля 2017, 11:14:24
dyvniy
write to sqlite3 datetime and read it
http://stackoverflow.com/questions/1829872/how-to ... me-instead-of-string-in-python

Код: Выделить всё

>>> 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))]