Первые шаги подключения BD к API

This commit is contained in:
2024-07-31 17:58:26 +09:00
parent da2ae23831
commit a2a400fff3
5 changed files with 46 additions and 0 deletions

View File

0
backend-app/repo/crud.py Normal file
View File

21
backend-app/repo/model.py Normal file
View File

@ -0,0 +1,21 @@
from database import Model
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String, Integer, Boolean, ForeignKey
from typing import Optional, Sequence
class UserModel(Model):
__tablename__ ="users"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
firstname: Mapped[str | None]= mapped_column(String(255), nullable=True)
lastname: Mapped[str | None]= mapped_column(String(255), nullable=True)
age: Mapped[int | None] = mapped_column(Integer, nullable=True)
email: Mapped[str | None] = mapped_column(String(255), nullable=True)
login_id: Mapped[int] = mapped_column(Integer, ForeignKey("logins.id"))
class LoginModel(Model):
__tablename__ ="logins"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
login: Mapped[str]= mapped_column(String(255), nullable=False)
password: Mapped[str]= mapped_column(String(255), nullable=False)

View File

@ -0,0 +1,2 @@
from pydantic import BaseModel