In the SQLite documentation, it says you can get the current date by running the query
SELECT date('now');
and indeed it works in the SQLite command line:
sqlite> SELECT date('now');
2012-03-03
However, when I try to use it in a Python program, the same query doesn’t work:
import sqlite3
conn=sqlite3.connect('results.db')
c=conn.cursor()
c.execute('SELECT date(now);')
says no such column: now.
Any suggestions?
You’re missing quotes around
now.Try
c.execute("SELECT date('now');")