Add db & pydantic models + set up alembic
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import secrets
|
||||
import warnings
|
||||
from typing import Annotated, Any, Literal
|
||||
from pydantic import (
|
||||
MySQLDsn
|
||||
)
|
||||
from pydantic_core import MultiHostUrl
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""
|
||||
"""
|
||||
model_config = SettingsConfigDict(
|
||||
# One level above ./backend
|
||||
env_file='../.env',
|
||||
env_ignore_empty=True,
|
||||
extra='ignore'
|
||||
)
|
||||
SECRET_KEY: str = secrets.token_urlsafe(32)
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8 # 8 days
|
||||
|
||||
MYSQL_SERVER: str
|
||||
MYSQL_PORT: int = 3306
|
||||
MYSQL_USER: str
|
||||
MYSQL_PASSWORD: str = ""
|
||||
MYSQL_DB: str = ""
|
||||
|
||||
@computed_field # type: ignore[prop-decorator]
|
||||
@property
|
||||
def SQLALCHEMY_DATABASE_URI(self) -> MySQLDsn:
|
||||
return MultiHostUrl.build(
|
||||
scheme="mysql+mysqldb",
|
||||
username=self.MYSQL_USER,
|
||||
password=self.MYSQL_PASSWORD,
|
||||
host=self.MYSQL_SERVER,
|
||||
port=self.MYSQL_PORT,
|
||||
path=self.MYSQL_DB
|
||||
) # type: ignore
|
||||
|
||||
settings = Settings() # type: ignore
|
||||
Reference in New Issue
Block a user