Skip to content

Commit

Permalink
Merge pull request #5 from black-redoc/feat/db_production_lib
Browse files Browse the repository at this point in the history
fix: fixed database connection error
  • Loading branch information
black-redoc committed May 24, 2024
2 parents 54e2c2b + 119f15a commit 568da31
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/settings/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
from sqlalchemy.orm import sessionmaker, declarative_base

SQLALCHEMY_DATABASE_URL = os.getenv("DATABASE_URL")

engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
ENVIRONMENT = os.getenv("ENVIRONMENT")

if ENVIRONMENT == "development":
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
else:
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()
Expand Down

0 comments on commit 568da31

Please sign in to comment.