add .gitignore, remove pycache

This commit is contained in:
Alexander Kalinovsky
2025-01-04 14:28:42 +01:00
parent 6dbe0536ca
commit 7793a0cb77
54 changed files with 10 additions and 18 deletions

View File

@@ -1,4 +1,3 @@
from sqlmodel import select
from sqlmodel.ext.asyncio.session import AsyncSession
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.orm import sessionmaker
@@ -14,20 +13,6 @@ async_session = sessionmaker[AsyncSession](
async_engine, class_=AsyncSession, expire_on_commit=False
)
async def init_db(session: AsyncSession) -> None:
from app.models import User, Language,Role
user = (await session.exec(
select(User).where(User.id == config.ADMIN_TELEGRAM_ID)
)).first()
if not user:
await User.create(session, User(
id = config.ADMIN_TELEGRAM_ID,
lang = Language.DEFAULT,
roles = [Role.SUPER_USER],
name = "Admin"), commit = True)
async def get_db() -> AsyncSession: # type: ignore
async with async_session() as session:
yield session