Add support of sqlachemy 2.0

Change-Id: I96b0e9f22753ee9173a921919d78edf646a4fc89
This commit is contained in:
wu.chunyang 2024-06-08 13:56:45 +08:00
parent 5eb7e702ad
commit f557061d23

View File

@ -16,6 +16,7 @@ import time
from oslo_log import log as logging
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
import sqlalchemy
from sqlalchemy import text
from tempest.lib import exceptions
LOG = logging.getLogger(__name__)
@ -62,13 +63,11 @@ class SQLClient(object):
def conn_execute(self, conn, cmds):
if isinstance(cmds, str):
result = conn.execute(cmds)
# Returns a ResultProxy
# https://docs.sqlalchemy.org/en/13/core/connections.html#sqlalchemy.engine.ResultProxy
result = conn.execute(text(cmds))
return result
for cmd in cmds:
conn.execute(cmd)
conn.execute(text(cmd))
def pgsql_execute(self, cmds, **kwargs):
try: