db를 maridaDB 사용하도록 수정
This commit is contained in:
@@ -10,4 +10,11 @@ class Settings(BaseSettings):
|
||||
hf_token: str = Field(alias="HF_TOKEN")
|
||||
serper_api_key: str = Field(alias="SERPER_API_KEY")
|
||||
|
||||
# MariaDB Database Configurations
|
||||
db_host: str = Field(default="192.168.1.10", alias="DB_HOST")
|
||||
db_port: int = Field(default=3306, alias="DB_PORT")
|
||||
db_user: str = Field(default="your_username", alias="DB_USER")
|
||||
db_password: str = Field(default="your_password", alias="DB_PASSWORD")
|
||||
db_name: str = Field(default="your_database_name", alias="DB_NAME")
|
||||
|
||||
settings = Settings()
|
||||
@@ -1,11 +1,15 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import DeclarativeBase, sessionmaker
|
||||
from pathlib import Path
|
||||
from backend.config.settings import settings
|
||||
|
||||
Path("db").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
engine = create_engine('sqlite:///db/roguelike.db', echo=True)
|
||||
# MariaDB Connection URL
|
||||
DATABASE_URL = f"mysql+pymysql://{settings.db_user}:{settings.db_password}@{settings.db_host}:{settings.db_port}/{settings.db_name}?charset=utf8mb4"
|
||||
|
||||
engine = create_engine(
|
||||
DATABASE_URL,
|
||||
echo=True,
|
||||
pool_pre_ping=True
|
||||
)
|
||||
|
||||
# 세션 팩토리 생성
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user