Spaces:
Sleeping
Sleeping
changed env variable from hard coded
Browse files- insert_data.py +4 -2
insert_data.py
CHANGED
@@ -10,6 +10,7 @@ DB_HOST = st.secrets["DB_HOST"]
|
|
10 |
DB_NAME = st.secrets["DB_NAME"]
|
11 |
DB_USER = st.secrets["DB_USER"]
|
12 |
DB_PASS = st.secrets["DB_PASS"]
|
|
|
13 |
|
14 |
def create_connection():
|
15 |
""" create a database connection to the SQLite database
|
@@ -18,9 +19,10 @@ def create_connection():
|
|
18 |
"""
|
19 |
conn = None
|
20 |
try:
|
21 |
-
|
|
|
22 |
except:
|
23 |
-
print(e)
|
24 |
|
25 |
return conn
|
26 |
|
|
|
10 |
DB_NAME = st.secrets["DB_NAME"]
|
11 |
DB_USER = st.secrets["DB_USER"]
|
12 |
DB_PASS = st.secrets["DB_PASS"]
|
13 |
+
DB_SSLMODE = st.secrets["SSLMODE"]
|
14 |
|
15 |
def create_connection():
|
16 |
""" create a database connection to the SQLite database
|
|
|
19 |
"""
|
20 |
conn = None
|
21 |
try:
|
22 |
+
db_uri = f"host={DB_HOST} dbname={DB_NAME} user={DB_USER} password={DB_PASS} sslmode=require"
|
23 |
+
conn = psycopg.connect(db_uri)
|
24 |
except:
|
25 |
+
print("Error during connection is \n", e)
|
26 |
|
27 |
return conn
|
28 |
|