
- Set up FastAPI project structure - Implement database models and migrations for file metadata - Create file upload endpoint with size validation - Implement file download and listing functionality - Add health check and API information endpoints - Create comprehensive documentation
23 lines
538 B
Python
23 lines
538 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from app.core.config import settings
|
|
|
|
# Create SQLAlchemy engine
|
|
engine = create_engine(
|
|
settings.SQLALCHEMY_DATABASE_URL,
|
|
connect_args={"check_same_thread": False}, # Only needed for SQLite
|
|
)
|
|
|
|
# Create a SessionLocal class for database sessions
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
# Dependency to get DB session
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|