db: turn on foreign keys

This commit is contained in:
Brian Warner 2016-06-23 16:26:36 -07:00
parent 74a1902fcd
commit 355ece3e47

View File

@ -35,6 +35,10 @@ def get_db(dbfile, target_version=TARGET_VERSION, stderr=sys.stderr):
except (EnvironmentError, sqlite3.OperationalError) as e:
raise DBError("Unable to create/open db file %s: %s" % (dbfile, e))
db.row_factory = dict_factory
db.execute("PRAGMA foreign_keys = ON")
problems = db.execute("PRAGMA foreign_key_check").fetchall()
if problems:
raise DBError("failed foreign key check: %s" % (problems,))
if must_create:
schema = get_schema(target_version)