Skip to content

Commit 3c6fd6a

Browse files
committed
🐛 bug hunting
1 parent 6b865d6 commit 3c6fd6a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

app/services/event_listener.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,12 @@ async def connect(self) -> None:
5555
"""Establish connection to PostgreSQL for listening to notifications."""
5656
try:
5757
# Parse the database URL for asyncpg connection
58-
db_url = str(self.settings.SQLALCHEMY_DATABASE_URI)
59-
if db_url.startswith("postgresql://"):
60-
db_url = db_url.replace("postgresql://", "postgresql+asyncpg://", 1)
61-
elif not db_url.startswith("postgresql+asyncpg://"):
62-
# Fallback to direct connection params
63-
db_url = "postgresql://postgres:password@localhost/postgres"
64-
65-
# Remove the +asyncpg part for asyncpg.connect
66-
connection_url = db_url.replace("postgresql+asyncpg://", "postgresql://")
58+
db_url = self.settings.SQLALCHEMY_ASYNC_URI
59+
60+
# Remove the +asyncpg part for asyncpg.connect and unhide the password
61+
connection_url = db_url.render_as_string(False).replace(
62+
"postgresql+asyncpg://", "postgresql://"
63+
)
6764

6865
self.connection = await asyncpg.connect(connection_url)
6966
logger.info("Connected to PostgreSQL for event listening")

0 commit comments

Comments
 (0)