so im trying to connect to a cloud postgreSQL that is made with render and its not connecting but im sure host name is correct. heres some code. def get_db_connection():
try:
conn = psycopg2.connect(
dbname=" ",
user=" ",
password=" ",
host=" ",
)
print("Database connection successful!")
return conn
except psycopg2.OperationalError as e:
print(f"OperationalError: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
return None
def save_chat_to_db(user_id, message, role):
conn = get_db_connection()
if conn is None:
print("Failed to connect to the database.")
return