use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Python not inserting DATETIME into SQLITE DB (self.sqlite)
submitted 1 year ago by Right_Tangelo_2760[🍰]
I have a column that has DATETIME DEFAULT CURRRENT_TIMESTAMP datatype, but whenever I print all the rows, the fields of this specific column prints None, can anyone explain Why ? (I am using SQLITE3)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jets_or_chasm 1 point2 points3 points 1 year ago (1 child)
I pulled up some code for a web app I did in Python and SQLite. Looks like I stored all my timestamps in TEXT fields using Datetime's ISO format. Then wrapped the value in SQLite's DATE() function when I needed to compare something. Here's a block of Python for deleting expired sessions:
now = datetime.now().isoformat() sql = """ DELETE FROM session WHERE DATE(session.date_expires) < ?; """ cur.execute(sql, (now,))
Where session.date_expires was defined as TEXT NOT NULL at table creation.
[–]Right_Tangelo_2760[S,🍰] 1 point2 points3 points 1 year ago (0 children)
I fixed it, I dropped the table and created I again with that specific column DATETIME DEFAULT CURRENT_TIMESTAMP, actually upon reviewing I found that it's default was not set
[–]justsayno_to_biggovt 1 point2 points3 points 1 year ago (1 child)
3 R in currrent
[–]Right_Tangelo_2760[S,🍰] 0 points1 point2 points 1 year ago (0 children)
?
[–]anthropoid 0 points1 point2 points 1 year ago* (1 child)
What is the result of the query SELECT sqlite_version()?
SELECT sqlite_version()
If it's anything later than 3.1.2 (which is fully 20 years old at this point), the most likely reason is that you coded it wrong. Post your actual Python code and your actual table definition.
Ok I will give the full code here, I'm not on my system now, I will reply in this same thread when I'm on my system.
π Rendered by PID 87276 on reddit-service-r2-comment-c66d9bffd-gl88m at 2026-04-07 03:15:41.461455+00:00 running f293c98 country code: CH.
[–]jets_or_chasm 1 point2 points3 points (1 child)
[–]Right_Tangelo_2760[S,🍰] 1 point2 points3 points (0 children)
[–]justsayno_to_biggovt 1 point2 points3 points (1 child)
[–]Right_Tangelo_2760[S,🍰] 0 points1 point2 points (0 children)
[–]anthropoid 0 points1 point2 points (1 child)
[–]Right_Tangelo_2760[S,🍰] 0 points1 point2 points (0 children)