feat(phase-0): scaffold backend + web + docker + DB schema
- docker-compose.yml: timescaledb-ha (timescaledb 2.27 + vectorscale + pgvector + pgai) + backend (FastAPI, CUDA 12.1) + web (Next.js 14) - docker-compose.gpu.yml: GPU profile overlay for RTX 3070 Ti - build.bat: Windows bootstrap, auto-detects nvidia-smi and selects GPU/CPU compose - backend: Dockerfile, pyproject.toml, FastAPI skeleton with /health and /health/db - DB migration 001_init.sql: symbols (with trigram search), ohlcv_daily/1m (hypertables), macro_daily, trading_value_daily, news (vector embedding), predictions (with user_triggered flag for on-demand UX), prediction_outcomes, model_performance - web: Next.js 14 + Tailwind + lightweight-charts placeholder - README: KIS/DART/HuggingFace token issuance guides + 10 seed tickers + run instructions
This commit is contained in:
30
backend/app/db/connection.py
Normal file
30
backend/app/db/connection.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.engine import Engine
|
||||
|
||||
from app.config import settings
|
||||
|
||||
|
||||
_engine: Engine | None = None
|
||||
|
||||
|
||||
def get_engine() -> Engine:
|
||||
global _engine
|
||||
if _engine is None:
|
||||
_engine = create_engine(settings.database_url, pool_pre_ping=True, future=True)
|
||||
return _engine
|
||||
|
||||
|
||||
def ping() -> dict[str, object]:
|
||||
"""Smoke-test: DB 연결 + 확장 확인."""
|
||||
eng = get_engine()
|
||||
with eng.connect() as conn:
|
||||
version = conn.execute(text("SELECT version()")).scalar()
|
||||
exts = conn.execute(
|
||||
text(
|
||||
"SELECT extname FROM pg_extension "
|
||||
"WHERE extname IN ('timescaledb','vector','pg_trgm') ORDER BY extname"
|
||||
)
|
||||
).scalars().all()
|
||||
return {"server": version, "extensions": list(exts)}
|
||||
Reference in New Issue
Block a user