Refactor config and database handling.
Move configuration logic to a more modular structure and enhance database URL generation using individual components from environment variables. Adjust database initialization to utilize the updated settings for improved maintainability and clarity.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
import os
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@db:5432/eventspace")
|
||||
from app.core.config import settings
|
||||
|
||||
engine = create_engine(SQLALCHEMY_DATABASE_URL)
|
||||
# Use the database URL from settings
|
||||
engine = create_engine(settings.database_url)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
Reference in New Issue
Block a user