This commit is contained in:
2024-03-01 00:07:25 +03:00
parent 02c6956763
commit 80e817d70a
17 changed files with 104 additions and 6 deletions

View File

@@ -0,0 +1 @@
from .models.basic import *

View File

@@ -1,3 +1,6 @@
from typing import Annotated
from fastapi import Depends
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker, declarative_base
@@ -16,3 +19,6 @@ BaseModel = declarative_base()
async def get_session() -> AsyncSession:
async with session_maker() as session:
yield session
DatabaseDependency = Annotated[AsyncSession, Depends(get_session)]

View File

@@ -1,4 +1,4 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy import Column, Integer, String, BigInteger, Boolean
from ..base import BaseModel
@@ -6,5 +6,7 @@ from ..base import BaseModel
class User(BaseModel):
__tablename__ = 'users'
id = Column(Integer, autoincrement=True, primary_key=True, index=True)
login = Column(String, unique=True)
password = Column(String, unique=True)
telegram_id = Column(BigInteger, nullable=False, index=True)
phone_number = Column(String)
is_admin = Column(Boolean, nullable=False, default=False)