avoid transaction for CREATE and DROP database

This commit is contained in:
Jan Dittberner 2015-01-10 17:58:00 +01:00
parent 0b1249ed5d
commit 0ddf72b323

View file

@ -135,13 +135,14 @@ def create_pgsql_database(dbname, username):
""" """
with _get_connection() as conn: with _get_connection() as conn:
with conn.cursor() as curs: conn.autocommit = True
curs.execute( curs = conn.cursor()
""" curs.execute(
CREATE DATABASE %(dbname)s OWNER %(username)s """
""", CREATE DATABASE %(dbname)s OWNER %(username)s
{'dbname': Ident(dbname), 'username': Ident(username)} """,
) {'dbname': Ident(dbname), 'username': Ident(username)}
)
@shared_task @shared_task
@ -155,10 +156,11 @@ def delete_pgsql_database(dbname):
""" """
with _get_connection() as conn: with _get_connection() as conn:
with conn.cursor() as curs: conn.autocommit = True
curs.execute( curs = conn.cursor()
""" curs.execute(
DROP DATABASE %(dbname)s """
""", DROP DATABASE %(dbname)s
{'dbname': Ident(dbname)} """,
) {'dbname': Ident(dbname)}
)