Skip to content

Commit

Permalink
Vector DB secure connections (#77)
Browse files Browse the repository at this point in the history
* Add SSL enable for Postgres

* Remove logger

* Add a description
  • Loading branch information
gaya3-zipstack authored Aug 1, 2024
1 parent a424e5b commit 0c30cec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/unstract/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__version__ = "0.39.0"

__version__ = "0.40.0"


def get_sdk_version():
Expand Down
6 changes: 6 additions & 0 deletions src/unstract/sdk/adapters/vectordb/postgres/src/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Constants:
PORT = "port"
USER = "user"
SCHEMA = "schema"
ENABLE_SSL = "enable_ssl"


class Postgres(VectorDBAdapter):
Expand Down Expand Up @@ -82,12 +83,17 @@ def _get_vector_db_instance(self) -> BasePydanticVectorStore:
table_name=self._collection_name,
embed_dim=dimension,
)
if self._config.get(Constants.ENABLE_SSL, True):
ssl_mode = "require"
else:
ssl_mode = "disable"
self._client = psycopg2.connect(
database=self._config.get(Constants.DATABASE),
host=self._config.get(Constants.HOST),
user=self._config.get(Constants.USER),
password=self._config.get(Constants.PASSWORD),
port=str(self._config.get(Constants.PORT)),
sslmode=ssl_mode,
)

return vector_db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"title": "Password",
"format": "password",
"default": ""
},
"enable_ssl": {
"type": "boolean",
"title": "Enable SSL",
"description": "On selecting the checkbox, data encryption using SSL is enabled",
"default": true
}
}
}

0 comments on commit 0c30cec

Please sign in to comment.