linkedin2/model/test.py

14 lines
420 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import asyncio
from sqlalchemy import select, func
from database import get_async_session, Job
async def count_jobs():
async for session in get_async_session(): # get_async_session возвращает async generator
result = await session.execute(select(func.count()).select_from(Job))
count = result.scalar_one()
print(f"Всего записей: {count}")
asyncio.run(count_jobs())