Skip to content

Commit

Permalink
upgrade psycopg2 to psycopg3
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Istrati committed Nov 1, 2024
1 parent 2f98aa6 commit 0ddf77e
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions app/anomaly-detector/anomaly_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
from boto3 import client as boto3_client
from pandas import get_dummies, to_datetime, concat, read_csv
from numpy import concatenate, array
from psycopg2 import connect
from psycopg import connect
from sklearn.preprocessing import StandardScaler
from sentence_transformers import SentenceTransformer
from pgvector.psycopg2 import register_vector
from kubernetes import client as k8s_client, config as k8s_config
from botocore.exceptions import ClientError

Expand Down Expand Up @@ -199,13 +198,7 @@ def connect_to_database(dbname, dbuser, dbpass, dbhost, dbport):
Connects to a PostgreSQL database using the provided configuration.
"""
try:
return connect(
host = dbhost,
port = dbport,
database = dbname,
user = dbuser,
password = dbpass,
)
return connect(f"host={dbhost} port={dbport} dbname={dbname} user={dbuser} password={dbpass}")
except Exception as e:
print(f"Error while connecting to PostgreSQL: {e}")
raise
Expand Down Expand Up @@ -272,7 +265,6 @@ def main():
config_map_values.get("DBPASS"),
host, port
)
register_vector(conn)

# for every S3 file
for csv_s3_key in csv_s3_keys:
Expand Down

0 comments on commit 0ddf77e

Please sign in to comment.