Spaces:
Sleeping
Sleeping
pjgerrits
commited on
Commit
·
e2401b8
1
Parent(s):
0b14f01
update secrets
Browse files
app.py
CHANGED
@@ -9,27 +9,27 @@ import os
|
|
9 |
st.set_page_config(layout="wide")
|
10 |
|
11 |
@st.cache_resource
|
12 |
-
def connect_to_db():
|
13 |
-
|
14 |
|
15 |
-
conn = connect_to_db()
|
16 |
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
# Function to fetch previously saved data points
|
35 |
def fetch_saved_data():
|
|
|
9 |
st.set_page_config(layout="wide")
|
10 |
|
11 |
@st.cache_resource
|
12 |
+
# def connect_to_db():
|
13 |
+
# return psycopg2.connect(**st.secrets["postgres"])
|
14 |
|
15 |
+
# conn = connect_to_db()
|
16 |
|
17 |
|
18 |
+
Function to connect to the database
|
19 |
+
def connect_to_db():
|
20 |
+
try:
|
21 |
+
conn = psycopg2.connect(
|
22 |
+
dbname=st.secrets["dbname"],
|
23 |
+
user=st.secrets["user"],
|
24 |
+
password=st.secrets["password"],
|
25 |
+
host=st.secrets["host"],
|
26 |
+
port=st.secrets["port"],
|
27 |
+
sslmode=st.secrets["ssl"]
|
28 |
+
)
|
29 |
+
return conn
|
30 |
+
except Exception as e:
|
31 |
+
st.error(f"An error occurred while connecting to the database: {e}")
|
32 |
+
return None
|
33 |
|
34 |
# Function to fetch previously saved data points
|
35 |
def fetch_saved_data():
|