Add DatabaseMiddleware

This commit is contained in:
2024-07-30 02:37:36 +03:00
parent 3ec83e408c
commit f62e05fd06
5 changed files with 39 additions and 4 deletions
+1
View File
@@ -2,6 +2,7 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase
from ..config import DatabaseConfig
from .models import User
def get_engine(config: DatabaseConfig):
+4 -1
View File
@@ -8,5 +8,8 @@ class User (Base):
__tablename__ = "user"
id: Mapped[int] = mapped_column(BIGINT, primary_key=True, unique=True, autoincrement=False)
username: Mapped[int] = mapped_column(String(32), unique=True, nullable=True)
username: Mapped[str] = mapped_column(String(32), unique=True, nullable=True)
# additional fields go here
def __init__(self, id: int, username: str):
super().__init__(id=id, username=username)