Skip to content

Commit

Permalink
Fix SQLAlchemy deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
elemental-lf committed Mar 18, 2022
1 parent 5353e73 commit 82a3e0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/benji/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def storage_usage(cls, filter_expression: str = None) -> Dict[str, Dict[str, int
sq_block, sq_storage, sq_version = aliased(Block), aliased(Storage), aliased(Version)
share_count_overall_sq = Session.query(func.count('*')).select_from(sq_block).join(sq_version).join(
sq_storage).filter((Storage.id == sq_storage.id) & (Block.uid_left == sq_block.uid_left) &
(Block.uid_right == sq_block.uid_right)).as_scalar()
(Block.uid_right == sq_block.uid_right)).scalar_subquery()

# noinspection PyComparisonWithNone
share_count_query = Session.query(
Expand Down Expand Up @@ -953,7 +953,7 @@ def _alembic_config():

def _database_tables(self) -> List[str]:
# Need to ignore internal SQLite table here
return [table for table in self._engine.table_names() if table != 'sqlite_sequence']
return [table for table in sqlalchemy.inspect(self._engine).get_table_names() if table != 'sqlite_sequence']

def _migration_needed(self, alembic_config: alembic_config_Config) -> Tuple[bool, str, str]:
table_names = self._database_tables()
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def init(self, _destroy: bool = False) -> None:
if _destroy:
Base.metadata.drop_all(self._engine)
# Drop alembic_version table
if self._engine.has_table('alembic_version'):
if sqlalchemy.inspect(self._engine).has_table('alembic_version'):
with self._engine.begin() as connection:
connection.execute(
sqlalchemy.sql.ddl.DropTable(sqlalchemy.Table('alembic_version', sqlalchemy.MetaData())))
Expand Down

0 comments on commit 82a3e0c

Please sign in to comment.