Hi all

sqlite3 does not have a DATE type, but the python module does a pretty good 
job of providing one -

>>> import sqlite3
>>> conn = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES)
>>> cur = conn.cursor()
>>> cur.execute('CREATE TABLE test (dob DATE)')
<sqlite3.Cursor object at 0x00FE9BE0>
>>> cur.execute('INSERT INTO TEST (dob) VALUES (?)', ('2015-03-31',))
<sqlite3.Cursor object at 0x00FE9BE0>
>>> cur.execute('SELECT * FROM test')
<sqlite3.Cursor object at 0x00FE9BE0>
>>> cur.fetchone()
(datetime.date(2015, 3, 31),)
>>>

However, the following does not return a date object -

>>> cur.execute('SELECT CAST(? AS DATE)', ('2015-03-31',))
<sqlite3.Cursor object at 0x00FE9BE0>
>>> cur.fetchone()
(2015,)
>>>

I don't know how easy this would be to implement, but it would be nice if it 
could be made to work.

Is it worth filing a feature request?

Frank Millman



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to