learnbuddy-app / src /db_models.py
tripathiji1312's picture
feat: Add application source code
6c678a9
Raw
History Blame Contribute Delete
590 Bytes
from pydantic import BaseModel, EmailStr
from datetime import datetime
# This is a Pydantic model that will be used to represent a User
# fetched from the database. It helps with type hinting and validation.
class User(BaseModel):
id: int
username: str
email: EmailStr
xp: int
class Config:
# This 'orm_mode' tells Pydantic to read the data even if it
# is not a dict, but an ORM model (or any other arbitrary object
# with attributes). This is what allows it to work with the
# database cursor's results.
from_attributes = True