Skip to content

Commit c6f74b5

Browse files
committed
fix: Fix external database password containing special characters connection failure
1 parent 2d10744 commit c6f74b5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

backend/common/core/config.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import secrets
2+
import urllib.parse
23
from typing import Annotated, Any, Literal
34

45
from pydantic import (
@@ -76,14 +77,15 @@ def all_cors_origins(self) -> list[str]:
7677
def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn | str:
7778
if self.SQLBOT_DB_URL:
7879
return self.SQLBOT_DB_URL
79-
return MultiHostUrl.build(
80-
scheme="postgresql+psycopg",
81-
username=self.POSTGRES_USER,
82-
password=self.POSTGRES_PASSWORD,
83-
host=self.POSTGRES_SERVER,
84-
port=self.POSTGRES_PORT,
85-
path=self.POSTGRES_DB,
86-
)
80+
# return MultiHostUrl.build(
81+
# scheme="postgresql+psycopg",
82+
# username=urllib.parse.quote(self.POSTGRES_USER),
83+
# password=urllib.parse.quote(self.POSTGRES_PASSWORD),
84+
# host=self.POSTGRES_SERVER,
85+
# port=self.POSTGRES_PORT,
86+
# path=self.POSTGRES_DB,
87+
# )
88+
return f"postgresql+psycopg://{urllib.parse.quote(self.POSTGRES_USER)}:{urllib.parse.quote(self.POSTGRES_PASSWORD)}@{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
8789

8890
MCP_IMAGE_PATH: str = '/opt/sqlbot/images'
8991
EXCEL_PATH: str = '/opt/sqlbot/data/excel'

0 commit comments

Comments
 (0)