
- Set up project structure and dependencies - Create database models for users, posts, comments, and tags - Set up Alembic for database migrations - Implement user authentication (register, login) - Create CRUD endpoints for blog posts, comments, and tags - Add health check endpoint - Set up proper error handling - Update README with project details and setup instructions
18 lines
565 B
Python
18 lines
565 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
from pathlib import Path
|
|
|
|
# Create the directory for the database if it doesn't exist
|
|
DB_DIR = Path("/app") / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
engine = create_engine(
|
|
SQLALCHEMY_DATABASE_URL,
|
|
connect_args={"check_same_thread": False}
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base() |