Merge "Fix "create database" failed for postgress"
This commit is contained in:
commit
5c12f72fc5
@ -0,0 +1,8 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix guest-agent failed to start postgres container due to execution
|
||||
of the "CREATE DATABASE" statement within the context manager of
|
||||
psycopg library. See the following for details
|
||||
`Stroy 2010761 <https://storyboard.openstack.org/#!/story/2010761>`__
|
||||
|
@ -770,12 +770,15 @@ class PostgresConnection(object):
|
||||
def _execute_stmt(self, statement, identifiers, data_values, fetch,
|
||||
autocommit=False):
|
||||
cmd = self._bind(statement, identifiers)
|
||||
with psycopg2.connect(self.connect_str) as connection:
|
||||
connection.autocommit = autocommit
|
||||
connection = psycopg2.connect(self.connect_str)
|
||||
connection.autocommit = autocommit
|
||||
try:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(cmd, data_values)
|
||||
if fetch:
|
||||
return cursor.fetchall()
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
def _bind(self, statement, identifiers):
|
||||
if identifiers:
|
||||
|
Loading…
Reference in New Issue
Block a user