diff --git a/data/crud.py b/data/crud.py index c04e0b0..58f86b7 100644 --- a/data/crud.py +++ b/data/crud.py @@ -38,6 +38,10 @@ async def read_all_connections(db: AsyncSession): result = await db.execute(select(Connection)) return result.scalars().all() +async def read_all_listenable_connection(db:AsyncSession): + result = await db.execute(select(Connection).filter(Connection.listen_updates == True)) + return result.scalars().all() + async def create_connection(db: AsyncSession, connection: ConnectionCreate, user_id: int): db_connection = Connection(**connection.model_dump(), owner_id=user_id) db.add(db_connection) diff --git a/utils/scripts.py b/utils/scripts.py index da6f834..2537b9c 100644 --- a/utils/scripts.py +++ b/utils/scripts.py @@ -30,9 +30,9 @@ async def shutdown(): async def mysql_streams_listeners_creator(): - from data.crud import read_all_connections + from data.crud import read_all_listenable_connection async with SessionLocal() as db: - connections = await read_all_connections(db=db) + connections = await read_all_listenable_connection(db=db) from utils.binlog import start_listeners start_listeners(connections=connections)