Skip to content

Commit 0ddf77e

Browse files
author
Eugene Istrati
committed
upgrade psycopg2 to psycopg3
1 parent 2f98aa6 commit 0ddf77e

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

app/anomaly-detector/anomaly_detector.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
from boto3 import client as boto3_client
1313
from pandas import get_dummies, to_datetime, concat, read_csv
1414
from numpy import concatenate, array
15-
from psycopg2 import connect
15+
from psycopg import connect
1616
from sklearn.preprocessing import StandardScaler
1717
from sentence_transformers import SentenceTransformer
18-
from pgvector.psycopg2 import register_vector
1918
from kubernetes import client as k8s_client, config as k8s_config
2019
from botocore.exceptions import ClientError
2120

@@ -199,13 +198,7 @@ def connect_to_database(dbname, dbuser, dbpass, dbhost, dbport):
199198
Connects to a PostgreSQL database using the provided configuration.
200199
"""
201200
try:
202-
return connect(
203-
host = dbhost,
204-
port = dbport,
205-
database = dbname,
206-
user = dbuser,
207-
password = dbpass,
208-
)
201+
return connect(f"host={dbhost} port={dbport} dbname={dbname} user={dbuser} password={dbpass}")
209202
except Exception as e:
210203
print(f"Error while connecting to PostgreSQL: {e}")
211204
raise
@@ -272,7 +265,6 @@ def main():
272265
config_map_values.get("DBPASS"),
273266
host, port
274267
)
275-
register_vector(conn)
276268

277269
# for every S3 file
278270
for csv_s3_key in csv_s3_keys:

0 commit comments

Comments
 (0)