Skip to content

Commit

Permalink
Merge pull request #228 from haohangyan/reverse_sqlalchemy
Browse files Browse the repository at this point in the history
Reverse changes related to sqlalchemy>2.0
  • Loading branch information
kkaris authored Oct 2, 2024
2 parents e777662 + 79dd506 commit 69438c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions indra_db/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from sqlalchemy.schema import DropTable
from sqlalchemy.sql.expression import Delete, Update
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.orm import declarative_base, DeclarativeMeta
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
from sqlalchemy import create_engine, inspect, UniqueConstraint, func
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.attributes import InstrumentedAttribute
Expand Down Expand Up @@ -249,11 +249,10 @@ class BaseMeta(DeclarativeMeta, IndraDBTableMetaClass):
# Check to see if the database if available.
self.available = True
try:
with create_engine(
self.url,
connect_args={'connect_timeout': 1}
).connect() as connection:
connection.execute('SELECT 1 AS ping;')
create_engine(
self.url,
connect_args={'connect_timeout': 1}
).execute('SELECT 1 AS ping;')
except Exception as err:
logger.warning(f"Database {repr(self.url)} is not available: {err}")
self.available = False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
author_email='[email protected]',
packages=packages,
include_package_data=True,
install_requires=['sqlalchemy', 'psycopg2', 'cachetools',
install_requires=['sqlalchemy<1.4', 'psycopg2', 'cachetools',
'termcolor'],
extras_require=extras_require,
entry_points="""
Expand Down

0 comments on commit 69438c8

Please sign in to comment.