Skip to content
Snippets Groups Projects
Commit 16dd87d8 authored by Erik Johnston's avatar Erik Johnston
Browse files

Don't assume db conn is a Context Manager.

Twisted adbapi wrapped connections aren't context managers.
parent 5eefd1f6
No related branches found
No related tags found
No related merge requests found
...@@ -583,7 +583,7 @@ def prepare_database(db_conn): ...@@ -583,7 +583,7 @@ def prepare_database(db_conn):
"""Prepares a database for usage. Will either create all necessary tables """Prepares a database for usage. Will either create all necessary tables
or upgrade from an older schema version. or upgrade from an older schema version.
""" """
with db_conn: try:
cur = db_conn.cursor() cur = db_conn.cursor()
version_info = _get_or_create_schema_state(cur) version_info = _get_or_create_schema_state(cur)
...@@ -596,6 +596,10 @@ def prepare_database(db_conn): ...@@ -596,6 +596,10 @@ def prepare_database(db_conn):
cur.execute("PRAGMA user_version = %d" % (SCHEMA_VERSION,)) cur.execute("PRAGMA user_version = %d" % (SCHEMA_VERSION,))
cur.close() cur.close()
db_conn.commit()
except:
db_conn.rollback()
raise
def _setup_new_database(cur): def _setup_new_database(cur):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment