-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
27 lines (22 loc) · 826 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import streamlit as st
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from guidelines import guidelines
user = os.environ.get("POSTGRES_USER")
passwd = os.environ.get("POSTGRES_PASSWORD")
host = os.environ.get("POSTGRES_HOST", "db")
port = os.environ.get("POSTGRES_PORT", 5432)
db = os.environ.get("POSTGRES_DB")
st.set_page_config(layout="wide")
guidelines()
try:
url = f"postgresql://{user}:{passwd}@{host}:{port}/{db}"
engine = create_engine(url, connect_args={'connect_timeout': 5})
Session = sessionmaker(bind=engine)
session = Session()
engine.connect()
# Load Guidelines
st.subheader("Database connection established. Go through the guidelines and Navigate to other pages.")
except Exception as e:
st.subheader("Database connection failed.")