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: I10d29d8079503927122cd8db19ac1476ebe82b9d
This commit is contained in:
Stephen Finucane 2023-06-16 19:46:39 -07:00
parent 60fb3cda60
commit 6da7e692ab
1 changed files with 5 additions and 2 deletions

View File

@ -228,12 +228,15 @@ class ForeignKeyConstraintFixture(fixtures.Fixture):
def _setUp(self):
if self.engine.name == 'sqlite':
self.engine.execute("PRAGMA foreign_keys=ON")
with self.engine.connect() as conn:
conn.exec_driver_sql("PRAGMA foreign_keys = ON")
def disable_fks():
with self.engine.connect() as conn:
conn.connection.rollback()
conn.execute("PRAGMA foreign_keys=OFF")
conn.exec_driver_sql("PRAGMA foreign_keys=OFF")
self.addCleanup(disable_fks)