Skip to content

Commit e48968f

Browse files
authored
📑 fix: quote variables in connection string and dsn (#149)
1 parent 8ae9896 commit e48968f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import boto3
55
import logging
6+
import urllib.parse
67
from enum import Enum
78
from datetime import datetime
89
from dotenv import find_dotenv, load_dotenv
@@ -67,8 +68,8 @@ def get_env_variable(
6768
env_value = get_env_variable("PDF_EXTRACT_IMAGES", "False").lower()
6869
PDF_EXTRACT_IMAGES = True if env_value == "true" else False
6970

70-
CONNECTION_STRING = f"postgresql+psycopg2://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{DB_HOST}:{DB_PORT}/{POSTGRES_DB}"
71-
DSN = f"postgresql://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{DB_HOST}:{DB_PORT}/{POSTGRES_DB}"
71+
CONNECTION_STRING = f"postgresql+psycopg2://{urllib.parse.quote_plus(POSTGRES_USER)}:{urllib.parse.quote_plus(POSTGRES_PASSWORD)}@{DB_HOST}:{DB_PORT}/{urllib.parse.quote_plus(POSTGRES_DB)}"
72+
DSN = f"postgresql://{urllib.parse.quote_plus(POSTGRES_USER)}:{urllib.parse.quote_plus(POSTGRES_PASSWORD)}@{DB_HOST}:{DB_PORT}/{urllib.parse.quote_plus(POSTGRES_DB)}"
7273

7374
## Logging
7475

0 commit comments

Comments
 (0)