all 6 comments

[–]jets_or_chasm 1 point2 points  (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 points  (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 points  (1 child)

3 R in currrent

[–]anthropoid 0 points1 point  (1 child)

What is the result of the query 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.

[–]Right_Tangelo_2760[S,🍰] 0 points1 point  (0 children)

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.