Use sqlalchemy text for ensuring session existence
Textual SQL expressions should be passed using text() method. Passing them as a simple string is deprecated and can be no longer used with modern sqlalchemy. This also squashes patch [1] which replaces pysnmp[1] that is no longer maintained with a fork pysnmp-lextudio[2] to resolve circular dependency [1] https://review.opendev.org/c/openstack/vitrage/+/918415 [2] https://github.com/lextudio/pysnmp Depends-On: https://review.opendev.org/c/openstack/vitrage-tempest-plugin/+/927167 Co-Authored-By: Takashi Kajinami <kajinamit@oss.nttdata.com> Change-Id: Ied45b260415826a09c9c2358d37c34452ab10f32
This commit is contained in:
parent
3887910d6b
commit
24dd49640d
@ -28,7 +28,7 @@ stevedore>=1.28.0 # Apache-2.0
|
|||||||
voluptuous>=0.11.1 # BSD License
|
voluptuous>=0.11.1 # BSD License
|
||||||
SQLAlchemy>=1.2.5 # MIT
|
SQLAlchemy>=1.2.5 # MIT
|
||||||
sympy>=1.1.1 # BSD
|
sympy>=1.1.1 # BSD
|
||||||
pysnmp>=4.4.4 # BSD
|
pysnmp-lextudio>=5.0.0 # BSD
|
||||||
PyJWT>=1.6.0 # MIT
|
PyJWT>=1.6.0 # MIT
|
||||||
osprofiler>=2.0.0 # Apache-2.0
|
osprofiler>=2.0.0 # Apache-2.0
|
||||||
keystoneauth1>=3.6.2 # Apache-2.0
|
keystoneauth1>=3.6.2 # Apache-2.0
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_db.sqlalchemy import enginefacade
|
from oslo_db.sqlalchemy import enginefacade
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from sqlalchemy import text
|
||||||
from stevedore import driver
|
from stevedore import driver
|
||||||
import tenacity
|
import tenacity
|
||||||
import threading
|
import threading
|
||||||
@ -56,7 +57,7 @@ def get_connection_from_config():
|
|||||||
"""Return an open connection to the database."""
|
"""Return an open connection to the database."""
|
||||||
conn = mgr.driver(url)
|
conn = mgr.driver(url)
|
||||||
with enginefacade.reader.using(_CONTEXT) as session:
|
with enginefacade.reader.using(_CONTEXT) as session:
|
||||||
session.execute('SELECT 1;')
|
session.execute(text('SELECT 1;'))
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
return _get_connection()
|
return _get_connection()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user