Skip to content

Commit

Permalink
Docker Compose Environment override fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed May 13, 2024
1 parent 0eba9db commit 38e5572
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fly.toml
.env
14 changes: 11 additions & 3 deletions api/src/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
from sqlalchemy.ext.declarative import declarative_base

load_dotenv(override=True)
load_dotenv()

connect_args = {}

Expand All @@ -15,7 +15,10 @@
connect_args = {"check_same_thread": False}

engine = create_async_engine(
os.environ["CONNECTION_URI"], connect_args=connect_args, echo=True
os.environ["CONNECTION_URI"],
connect_args=connect_args,
echo=True,
pool_pre_ping=True,
)

SessionLocal = async_sessionmaker(autocommit=False, autoflush=False, bind=engine)
Expand All @@ -26,6 +29,11 @@ def scaffold_db():
"""use a sync engine for scaffolding the database. ddl operations are unavailable
with async engines
"""
engine = create_engine(os.environ["CONNECTION_URI"], echo=True)
print(os.environ["CONNECTION_URI"])
engine = create_engine(
os.environ["CONNECTION_URI"],
pool_pre_ping=True,
echo=True,
)
Base.metadata.create_all(bind=engine)
engine.dispose()

0 comments on commit 38e5572

Please sign in to comment.