mirror of
https://mau.dev/maunium/synapse.git
synced 2024-11-18 07:52:56 +01:00
Wrap preparing the database in a transaction. Otherwise it will take many seconds to complete because sqlite will create a transaction per statement
This commit is contained in:
parent
1342bcedaf
commit
db2e350e29
1 changed files with 4 additions and 3 deletions
|
@ -452,9 +452,10 @@ def prepare_database(db_conn):
|
||||||
db_conn.commit()
|
db_conn.commit()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
sql_script = "BEGIN TRANSACTION;"
|
||||||
for sql_loc in SCHEMAS:
|
for sql_loc in SCHEMAS:
|
||||||
sql_script = read_schema(sql_loc)
|
sql_script += read_schema(sql_loc)
|
||||||
|
sql_script += "COMMIT TRANSACTION;"
|
||||||
c.executescript(sql_script)
|
c.executescript(sql_script)
|
||||||
db_conn.commit()
|
db_conn.commit()
|
||||||
c.execute("PRAGMA user_version = %d" % SCHEMA_VERSION)
|
c.execute("PRAGMA user_version = %d" % SCHEMA_VERSION)
|
||||||
|
|
Loading…
Reference in a new issue