From 6e0940aaf23defdaf62a861882d87db08faa7c29 Mon Sep 17 00:00:00 2001 From: rrr-marble Date: Fri, 2 Jul 2021 15:45:50 +0300 Subject: [PATCH] add: create sessions and marks tables in new db --- util/import_photos.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/util/import_photos.py b/util/import_photos.py index 1ab1a5a..af4d120 100644 --- a/util/import_photos.py +++ b/util/import_photos.py @@ -131,6 +131,36 @@ def check_database(database_path: str): )""" ) con.commit() + + # create the rest of the tables, while we're at it + cur.execute( + """CREATE TABLE sessions + ( + sessionid INTEGER PRIMARY KEY, + cookie TEXT UNIQUE NOT NULL, + description TEXT + )""" + ) + con.commit() + + cur.execute( + """CREATE TABLE marks + ( + imgid INTEGER, + sessionid INTEGER, + mark INTEGER, + PRIMARY KEY (imgid, sessionid), + FOREIGN KEY (imgid) + REFERENCES images (imgid) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + FOREIGN KEY (sessionid) + REFERENCES sessions (sessionid) + ON DELETE NO ACTION + ON UPDATE NO ACTION + )""" + ) + con.commit() # we only use this occasionaly with new databases, # so don't bother with transfer logic, just close and reopen it later con.close()