db: Don't pass strings to 'Connection.execute'

Resolve the following RemovedIn20Warning warning:

  Passing a string to Connection.execute() is deprecated and will be
  removed in version 2.0.  Use the text() construct, or the
  Connection.exec_driver_sql() method to invoke a driver-level SQL
  string.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: Ic4518ca1a5aea94a72c9dc3e4393eb970b55c3dd
This commit is contained in:
Stephen Finucane 2023-09-21 13:05:59 +01:00
parent 45e0eaaa61
commit 3bd47b2b50
1 changed files with 4 additions and 2 deletions

View File

@ -52,7 +52,9 @@ class PgSQLManager(SQLManager):
@staticmethod
def _create_db(conn, db_name):
conn.connection.set_isolation_level(0)
conn.execute('CREATE DATABASE %s WITH TEMPLATE template0;' % db_name)
conn.exec_driver_sql(
'CREATE DATABASE %s WITH TEMPLATE template0;' % db_name
)
conn.connection.set_isolation_level(1)
@ -60,7 +62,7 @@ class MySQLManager(SQLManager):
@staticmethod
def _create_db(conn, db_name):
conn.execute('CREATE DATABASE %s;' % db_name)
conn.exec_driver_sql('CREATE DATABASE %s;' % db_name)
class SQLiteManager(fixtures.Fixture):