From cbefc55921e19125acbc155593d3acfa77a4b507 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sun, 25 Nov 2012 13:44:06 -0800 Subject: Or I could just use transactions...derp :/ much nicer now --- framework/database.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/framework/database.py b/framework/database.py index 6f899ba..e89a2e7 100644 --- a/framework/database.py +++ b/framework/database.py @@ -61,11 +61,8 @@ class ResultDatabase: return date def addPlaceholderResults(self, run, tests): - #rows = [(run, test) for test in tests] + rows = [(run, test) for test in tests] c = self.connection.cursor() - #c.executemany('INSERT INTO results(run_id, test_name) VALUES(?,?)', rows) - testlist = list(tests) - batches = [testlist[x:x+500] for x in range(0, len(testlist), 500)] - for batch in batches: - query = 'INSERT INTO results(run_id, test_name) VALUES (' + '),('.join([str(run) + ',' + "'" + test.replace("'", '') + "'" for test in batch]) + ')' - c.execute(query) + c.execute('BEGIN IMMEDIATE TRANSACTION') + c.executemany('INSERT INTO results(run_id, test_name) VALUES(?,?)', rows) + c.execute('END TRANSACTION') -- cgit v1.2.3