diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 13:44:06 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 13:44:22 -0800 |
commit | cbefc55921e19125acbc155593d3acfa77a4b507 (patch) | |
tree | 088e3644f10f5dd07703966aa66720d55d3db24d | |
parent | 85501f5aadccd7f1d247ef58df16b2560cc1dcab (diff) |
Or I could just use transactions...derp :/ much nicer now
-rw-r--r-- | framework/database.py | 11 |
1 files 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') |