diff --git a/api/.dockerignore b/api/.dockerignore index 0501d09..b78cabd 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -1 +1,2 @@ fly.toml +.env diff --git a/api/src/db.py b/api/src/db.py index de43eda..e45a964 100644 --- a/api/src/db.py +++ b/api/src/db.py @@ -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 = {} @@ -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) @@ -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()