File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ The following environment variables are required to run the application:
4343- ` RAG_OPENAI_BASEURL ` : (Optional) The base URL for your OpenAI API Embeddings
4444- ` RAG_OPENAI_PROXY ` : (Optional) Proxy for OpenAI API Embeddings
4545- ` VECTOR_DB_TYPE ` : (Optional) select vector database type, default to ` pgvector ` .
46+ - ` POSTGRES_USE_UNIX_SOCKET ` : (Optional) Set to "True" when connecting to the PostgreSQL database server with Unix Socket.
4647- ` POSTGRES_DB ` : (Optional) The name of the PostgreSQL database, used when ` VECTOR_DB_TYPE=pgvector ` .
4748- ` POSTGRES_USER ` : (Optional) The username for connecting to the PostgreSQL database.
4849- ` POSTGRES_PASSWORD ` : (Optional) The password for connecting to the PostgreSQL database.
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ def get_env_variable(
5050VECTOR_DB_TYPE = VectorDBType (
5151 get_env_variable ("VECTOR_DB_TYPE" , VectorDBType .PGVECTOR .value )
5252)
53+ POSTGRES_USE_UNIX_SOCKET = (
54+ get_env_variable ("POSTGRES_USE_UNIX_SOCKET" , "False" ).lower () == "true"
55+ )
5356POSTGRES_DB = get_env_variable ("POSTGRES_DB" , "mydatabase" )
5457POSTGRES_USER = get_env_variable ("POSTGRES_USER" , "myuser" )
5558POSTGRES_PASSWORD = get_env_variable ("POSTGRES_PASSWORD" , "mypassword" )
@@ -69,8 +72,13 @@ def get_env_variable(
6972env_value = get_env_variable ("PDF_EXTRACT_IMAGES" , "False" ).lower ()
7073PDF_EXTRACT_IMAGES = True if env_value == "true" else False
7174
72- 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 )} "
73- 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 )} "
75+ if POSTGRES_USE_UNIX_SOCKET :
76+ connection_suffix = f"{ urllib .parse .quote_plus (POSTGRES_USER )} :{ urllib .parse .quote_plus (POSTGRES_PASSWORD )} @/{ urllib .parse .quote_plus (POSTGRES_DB )} ?host={ urllib .parse .quote_plus (DB_HOST )} "
77+ else :
78+ connection_suffix = f"{ urllib .parse .quote_plus (POSTGRES_USER )} :{ urllib .parse .quote_plus (POSTGRES_PASSWORD )} @{ DB_HOST } :{ DB_PORT } /{ urllib .parse .quote_plus (POSTGRES_DB )} "
79+
80+ CONNECTION_STRING = f"postgresql+psycopg2://{ connection_suffix } "
81+ DSN = f"postgresql://{ connection_suffix } "
7482
7583## Logging
7684
You can’t perform that action at this time.
0 commit comments