Replace "Inspector.from_engine()" with "sqlalchemy.inspect()"

Since SQLAlchemy 1.4, the method "Inspector.from_engine()" is
deprecated.

This patch is related to [1].

[1]https://review.opendev.org/c/openstack/neutron/+/808103

Related-Bug: #1943155
Change-Id: Ic26da2e20c0878204cf9565e173b4825cb36f34c
This commit is contained in:
Rodolfo Alonso Hernandez 2022-06-29 18:42:18 +00:00
parent 732c1dcbc2
commit d7ba5948ff
2 changed files with 2 additions and 3 deletions

View File

@ -47,8 +47,7 @@ def get_inspector():
if _INSPECTOR:
return _INSPECTOR
else:
bind = op.get_bind()
_INSPECTOR = sa.engine.reflection.Inspector.from_engine(bind)
_INSPECTOR = sa.inspect(op.get_bind())
return _INSPECTOR

View File

@ -85,7 +85,7 @@ def upgrade():
def clear_constraints_and_foreign():
inspect = sa.engine.reflection.Inspector.from_engine(op.get_bind())
inspect = sa.inspect(op.get_bind())
foreign_keys = inspect.get_foreign_keys(PF_TABLE_NAME)
migration.remove_foreign_keys(PF_TABLE_NAME,
foreign_keys)