add: create sessions and marks tables in new db

main
rrr-marble 5 years ago
parent 400a9e3c98
commit 6e0940aaf2

@ -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()

Loading…
Cancel
Save