'How to insert datetime into sqlite3 database using Python?
I would like to insert datetime into sqlite using Python.
I tried using Python's datetime and strftime but it didn't work.
Test's time field has the type of Numeric (Datetime).
from datetime import datetime as dt
rows = db.execute(
'INSERT INTO test (time) VALUES (:time)',
time=dt.now().strftime('%Y-%m-%d %H:%M:%S'))
RuntimeError: (sqlite3.OperationalError) near "'2019-05-19 17:14:25'": syntax error [SQL: INSERT INTO test (time) VALUES ('2019-05-19 17:14:25')]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
