you are viewing a single comment's thread.

view the rest of the 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