-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (32 loc) · 1.21 KB
/
app.py
File metadata and controls
38 lines (32 loc) · 1.21 KB
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
28
29
30
31
32
33
34
35
36
37
38
import pyTigerGraphBeta as tg
import streamlit as st
import tasks
def main():
"""
Gets login credentials from the user and
establishes a connection to the TigerGraph database
"""
st.title("TigerGraph Visual Query Tool")
st.write("Welcome to my first Streamlit + TigerGraph project connecting a web application to a graph database and visualizing query data.")
graph = None
authToken = None
sb = st.sidebar
sb.header("Connect to TigerGraph Database")
host = sb.text_input("Host URL")
username = sb.text_input("Username")
password = sb.text_input("Password", type="password")
graphname = sb.text_input("Graph Name")
if sb.checkbox("Connect to Graph"):
# establish connection to TG database
graph = tg.TigerGraphConnection(
host=host,
username=username,
password=password,
graphname=graphname,
)
st.success(f"Connected to {graphname} graph")
secret = sb.text_input("Secret", type="password")
if (sb.checkbox("Get Auth Token")):
# get auth token using user inputted secret
authToken = graph.getToken(secret)
tasks.main(graph, authToken)