Commit cb6b2f90 authored by Mattia Rizzolo's avatar Mattia Rizzolo

reproducible: _db_maintenance: run the update queries in a single

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <>
parent 26739d90
......@@ -14,10 +14,11 @@
import re
import sys
from datetime import datetime
from sqlalchemy.orm import sessionmaker
from rblib import query_db
from rblib.confparse import log
from rblib.const import DB_METADATA
from rblib.const import DB_ENGINE, DB_METADATA
from rblib.utils import print_critical_message
now ="%Y-%m-%d-%H-%M-%S")
......@@ -686,12 +687,15 @@ def db_update():
' the last update available.\nPlease check!')
sys.exit(1)'Found schema updates.')
Session = sessionmaker(bind=DB_ENGINE, autocommit=True)
session = Session()
for update in range(current+1, last+1):'Applying database update #' + str(update) + '. Queries:')
startTime =
for query in schema_updates[update]:'\t' + query)
with session.begin():
for query in schema_updates[update]:'\t' + query)
session.execute(query)[update])) + ' queries executed in ' +
str( - startTime))
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment