Skip to content

Commit 2c658e4

Browse files
committed
db_config.set comes in a later version of sqlalchemy. Re-construct URL instead.
1 parent c50de6c commit 2c658e4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

app/application.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,17 @@ def get_synchronous_db() -> Iterator[Session]:
4343
if SessionLocal is None:
4444
# Create a synchronous database URL using psycopg2 instead of asyncpg
4545
# asyncpg only works with async engines, not synchronous ones
46-
db_url = GLOBALS.database_config.url
47-
sync_url = db_url.set(drivername="postgresql+psycopg2")
46+
from sqlalchemy.engine.url import URL
47+
48+
db_config = GLOBALS.database_config
49+
sync_url = URL(
50+
drivername="postgresql+psycopg2",
51+
username=db_config.username,
52+
password=str(db_config.password) if db_config.password else None,
53+
host=db_config.host,
54+
port=db_config.port,
55+
database=db_config.database,
56+
)
4857
engine = create_engine(sync_url, pool_size=5, max_overflow=0)
4958
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
5059

docker-compose.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
networks:
4646
- gfw-tile-cache_test_default
4747
ports:
48-
- "54322:5432"
48+
- "54321:5432"
4949
environment:
5050
- POSTGRES_PORT=5432
5151
- POSTGRES_DB=_test

0 commit comments

Comments
 (0)