
- Replace EmailStr with custom email validation using regex
- Remove pydantic[email] dependency to prevent import errors
- Update config to use dynamic database path with proper directory creation
- Improve database session configuration with connection pooling
- Fix application startup failures caused by missing email-validator package
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
445 B
Python
20 lines
445 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from app.core.config import settings
|
|
|
|
engine = create_engine(
|
|
settings.SQLALCHEMY_DATABASE_URL,
|
|
connect_args={"check_same_thread": False},
|
|
pool_pre_ping=True,
|
|
pool_recycle=300
|
|
)
|
|
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close() |