From 10e55648d9aa5514390fd3dc816ae621f4e538b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 22 Feb 2008 13:57:24 +0100 Subject: [PATCH] Set isolation level to autocommit for create/drop database --- trytond/web_service/db.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trytond/web_service/db.py b/trytond/web_service/db.py index 1bcd4eca08..33715f0c86 100644 --- a/trytond/web_service/db.py +++ b/trytond/web_service/db.py @@ -7,6 +7,7 @@ from trytond import pooler from trytond import tools import base64 import os +from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT class DB(Service): @@ -32,6 +33,7 @@ class DB(Service): try: database = sql_db.db_connect('template1', serialize=1) cursor = database.cursor() + cursor.conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cursor.execute('CREATE DATABASE ' + db_name + ' ENCODING \'unicode\'') cursor.commit() cursor.close() @@ -55,7 +57,7 @@ class DB(Service): 'FROM res_user ' \ 'WHERE login <> \'root\' ORDER BY login') res = cursor.dictfetchall() - except Exception, e: + except: logger.notify_channel("web-service", LOG_ERROR, 'CREATE DB: %s failed' % (db_name,)) raise @@ -73,6 +75,7 @@ class DB(Service): database = sql_db.db_connect('template1', serialize=1) cursor = database.cursor() + cursor.conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) try: try: cursor.execute('DROP DATABASE ' + db_name)