From 0718de20fb8f051fcf6a99a7a2fa31be567de4d4 Mon Sep 17 00:00:00 2001 From: Darksider3 Date: Wed, 16 Oct 2019 14:00:57 +0200 Subject: [PATCH] Let SQLite check for incorrect dates on timestamp row --- public/userapplication.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/userapplication.py b/public/userapplication.py index e751717..7639040 100755 --- a/public/userapplication.py +++ b/public/userapplication.py @@ -46,7 +46,9 @@ def __createTable(cursor, connection): "id INTEGER PRIMARY KEY AUTOINCREMENT," "username TEXT NOT NULL, email TEXT NOT NULL," "name TEXT NOT NULL, pubkey TEXT NOT NULL," - "timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, status INTEGER NOT NULL DEFAULT 0);") + "timestamp DATETIME DEFAULT CURRENT_TIMESTAMP CONSTRAINT " + "timestamp_valid CHECK( timestamp IS strftime('%Y-%m-%d %H:%M:%S', timestamp))" + ",status INTEGER NOT NULL DEFAULT 0);") connection.commit() except sqlite3.Error as e: logging.exception("Couldn't create needed SQLite Table! Exception: %s" % e)