Fix RemovedIn20Warning: engine.execute() (note)

test/unit/data/model/test_mapping.py::TestCleanupEvent::test_table
  /home/sergey/0dev/galaxy/_galaxy/dev/lib/galaxy/model/view/utils.py:80: RemovedIn20Warning: The Engine.execute() method is considered legacy as of the 1.x series of SQLAlchemy and will be removed in 2.0. All statement execution in SQLAlchemy 2.0 is performed by the Connection.execute() method of Connection, or in the ORM by the Session.execute() method of Session. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    engine.execute(CreateView(view.name, view.__view__))

https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#execute-method-more-strict-execution-options-are-more-prominent
This commit is contained in:
Sergey Golitsynskiy
2022-01-12 13:51:09 -05:00
parent 99e0c5cf75
commit daeb6cd42b
+2 -1
View File
@@ -200,4 +200,5 @@ def execute_statements(engine, raw_sql):
statements = raw_sql if isinstance(raw_sql, list) else [raw_sql]
for sql in statements:
cmd = DDL(sql)
cmd.execute(bind=engine)
with engine.connect() as connection:
connection.execute(cmd)