From c8802ef7ef6f0f3b91c66db9f5fe0edf0ed8498f Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Thu, 15 Sep 2016 18:48:47 +0100 Subject: [PATCH] Bug 1303102 - Use autocommit for the run_sql command This prevents changes from being discarded if the DB connection timed out between the `.execute()` call being made, and it completing. --- treeherder/model/management/commands/run_sql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/treeherder/model/management/commands/run_sql.py b/treeherder/model/management/commands/run_sql.py index 3614ea9df..a9c7e51c9 100644 --- a/treeherder/model/management/commands/run_sql.py +++ b/treeherder/model/management/commands/run_sql.py @@ -75,8 +75,8 @@ class Command(BaseCommand): ) try: cursor = conn.cursor() + conn.autocommit(True) cursor.execute(sql_code) - conn.commit() self.stdout.write("Sql code executed on {}:".format(datasource)) for row in cursor: self.stdout.write(" {}".format(row))