Commit 46496c6e authored by echel0n's avatar echel0n

Refactored database restores to use bulk inserts for data, performance fix.

parent 88f70cf7
......@@ -346,8 +346,10 @@ class SRDatabase(object):
sickrage.app.log.info('Restoring {} database table {} data'.format(self.name, table_name))
table = base.classes[table_name]
session.query(table).delete()
rows = []
for row in loads(data, meta, session):
if isinstance(row, KeyedTuple):
row = table(**row._asdict())
session.merge(row)
rows.append(row._asdict())
session.bulk_insert_mappings(table, rows)
session.commit()
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