From 24dd49640d9e864f53f63f30e0298019ba6d6f35 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 26 Aug 2024 16:01:59 +0200 Subject: [PATCH] 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 Change-Id: Ied45b260415826a09c9c2358d37c34452ab10f32 --- requirements.txt | 2 +- vitrage/storage/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 47c318983..3aa8c6bdf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,7 @@ stevedore>=1.28.0 # Apache-2.0 voluptuous>=0.11.1 # BSD License SQLAlchemy>=1.2.5 # MIT sympy>=1.1.1 # BSD -pysnmp>=4.4.4 # BSD +pysnmp-lextudio>=5.0.0 # BSD PyJWT>=1.6.0 # MIT osprofiler>=2.0.0 # Apache-2.0 keystoneauth1>=3.6.2 # Apache-2.0 diff --git a/vitrage/storage/__init__.py b/vitrage/storage/__init__.py index 3bd9a5cd6..06a5b5bdc 100644 --- a/vitrage/storage/__init__.py +++ b/vitrage/storage/__init__.py @@ -15,6 +15,7 @@ from oslo_config import cfg from oslo_db.sqlalchemy import enginefacade from oslo_log import log +from sqlalchemy import text from stevedore import driver import tenacity import threading @@ -56,7 +57,7 @@ def get_connection_from_config(): """Return an open connection to the database.""" conn = mgr.driver(url) with enginefacade.reader.using(_CONTEXT) as session: - session.execute('SELECT 1;') + session.execute(text('SELECT 1;')) return conn return _get_connection()