[issue13568] sqlite3 convert_date error with DATE type
Filip Gruszczyński
report at bugs.python.org
Sat Dec 10 23:22:41 CET 2011
Filip Gruszczyński <gruszczy at gmail.com> added the comment:
c.execute("insert into testdate values ('now')")
This works, but you actually are putting string "now" into a field with DATE type. When conversion occurs after retrieving data, there is an error. Also if you use datetime() function
c.execute("insert into testdate values (datetime())")
you'll get an error later during conversion, because python expects date string and will get datetime string. This should work for you:
>>> c.execute("insert into testdate values (date())")
>>> x = c.execute("select * from testdate")
>>> for a in x:
... print(a)
...
(datetime.date(2011, 12, 10),)
----------
nosy: +gruszczy
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13568>
_______________________________________
More information about the Python-bugs-list
mailing list