From 6da7e692abe9cadd813ae2fb2a75a24da5e1603e Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 Jun 2023 19:46:39 -0700 Subject: [PATCH] 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 Change-Id: I10d29d8079503927122cd8db19ac1476ebe82b9d --- heat/tests/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/heat/tests/utils.py b/heat/tests/utils.py index 44c81c2942..d5ca3d3ffb 100644 --- a/heat/tests/utils.py +++ b/heat/tests/utils.py @@ -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)