Python Forum

Full Version: sqlite3 insert date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have a table that has thedate field with text data type. I am trying to insert current date:

    c2.execute("INSERT INTO exam_registration_history VALUES (:name, :exam_type, :token, :taken, :enabled, :thedate)",
        {
            'name': thefullname,
            'exam_type': theexamchoosen,
            'token': '',
            'taken': '',
            'enabled': '',
            'thedate': 'datetime("now")',
        })
i get the string stored as it is datetime("now") and not the date and if I take the quotes datetime('now') i get this error:
Error:
'thedate': datetime("now"), TypeError: an integer is required (got type str)
thanks
I replaced it with:
date.today()
it is working now.