pjgerrits commited on
Commit
e2401b8
1 Parent(s): 0b14f01

update secrets

Browse files
Files changed (1) hide show
  1. app.py +18 -18
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
- 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.write(st.secrets["DB_NAME"]),
23
- # user=st.write(st.secrets["DB_USER"]),
24
- # password=st.write(st.secrets["DB_PASS"]),
25
- # host=st.write(st.secrets["DB_HOST"]),
26
- # port=st.write(st.secrets["DB_PORT"]),
27
- # sslmode='prefer'
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():
 
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():