You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
853 B
Python

import psycopg2
def get_connection():
try:
# Konfigurasi koneksi database
# connection = psycopg2.connect(
# host="localhost",
# port=5432,
# database="postgres",
# user="postgres",
# password="ariwa"
# )
connection = psycopg2.connect(
dbname="digital_twin",
user="postgres",
password="postgres",
host="192.168.1.85",
port="5432",
)
connection_wo_db = psycopg2.connect(
dbname="digital_twin",
user="postgres",
password="postgres",
host="192.168.1.86",
port="5432",
)
return connection, connection_wo_db
except Exception as e:
print("Error saat koneksi ke database:", e)
return None