[FIX] fix problem create db when already exists
bzr revid: pja@tinyerp.com-20121112103321-v39900rc6tu0pvmb
This commit is contained in:
parent
be03940d64
commit
8e58d8d17c
|
@ -120,6 +120,12 @@ class db(netsvc.ExportService):
|
|||
db = sql_db.db_connect('postgres')
|
||||
cr = db.cursor()
|
||||
chosen_template = tools.config['db_template']
|
||||
cr.execute("""SELECT datname
|
||||
FROM pg_database
|
||||
WHERE datname = %s """,
|
||||
(name,))
|
||||
if cr.fetchall():
|
||||
raise openerp.exceptions.Warning(" %s database already exists!" % name )
|
||||
try:
|
||||
cr.autocommit(True) # avoid transaction block
|
||||
cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ % (name, chosen_template))
|
||||
|
|
Loading…
Reference in New Issue