db: Use raw connection to enable foreign keys
SQLAlchemy 2.0 wraps mostly everything in transactions, which limits our ability to do this easily on a non-global basis. Use the raw connection [1] instead. [1] https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.execute Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Change-Id: Ic2bbf59550e965769c6b64f3e5eeec9783c6b290
This commit is contained in:
parent
9b754a019e
commit
4d882edc30
@ -231,12 +231,12 @@ class ForeignKeyConstraintFixture(fixtures.Fixture):
|
||||
if self.engine.name == 'sqlite':
|
||||
|
||||
with self.engine.connect() as conn:
|
||||
conn.exec_driver_sql("PRAGMA foreign_keys = ON")
|
||||
conn.connection.execute("PRAGMA foreign_keys = ON")
|
||||
|
||||
def disable_fks():
|
||||
with self.engine.connect() as conn:
|
||||
conn.connection.rollback()
|
||||
conn.exec_driver_sql("PRAGMA foreign_keys=OFF")
|
||||
conn.connection.execute("PRAGMA foreign_keys = OFF")
|
||||
|
||||
self.addCleanup(disable_fks)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user