awacke1 commited on
Commit
7c5d3b6
Β·
1 Parent(s): c55395e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import streamlit as st
2
  from azure.cosmos import CosmosClient
3
- import os
4
 
5
  # Load and save query files
6
  def load_query(filename):
@@ -14,20 +13,21 @@ def save_query(filename, query):
14
  # Streamlit UI
15
  st.title("Azure Cosmos DB Explorer πŸ‘½")
16
 
17
- # Environment Variables for Cosmos DB Credentials
18
- ACCOUNT_URI = os.environ.get('ACCOUNT_URI', 'Your Cosmos DB URI here')
19
- ACCOUNT_KEY = os.environ.get('ACCOUNT_KEY', 'Your Cosmos DB Key here')
20
 
21
  client = None
22
 
23
  # Connection Details Expander
24
  with st.expander("Connect 🌍"):
25
- st.write("Environment Variables for Cosmos DB Credentials are pre-loaded.")
 
26
  database_name = st.text_input("Database Name:", "")
27
  container_name = st.text_input("Container Name:", "")
28
  if st.button("Connect"):
29
  try:
30
- client = CosmosClient(ACCOUNT_URI, credential=ACCOUNT_KEY)
31
  database_client = client.get_database_client(database_name)
32
  container_client = database_client.get_container_client(container_name)
33
  st.success("Connected successfully! πŸŽ‰")
@@ -72,8 +72,4 @@ with st.expander("Query Editor πŸ“"):
72
  st.markdown("""
73
  ## Instructions to Run this App:
74
 
75
- 1. **Environment Variables**: Set the `ACCOUNT_URI` and `ACCOUNT_KEY` environment variables with your Azure Cosmos DB URI and Key respectively.
76
- 2. **Install Packages**: If you haven't, install the required Python packages:
77
- 3. **Run App**: Save this code in a file, say `streamlit_cosmosdb_app.py`, and then run `streamlit run streamlit_cosmosdb_app.py`.
78
- 4. **Execute**: Use the UI to connect and run SQL queries against your Cosmos DB.
79
- """)
 
1
  import streamlit as st
2
  from azure.cosmos import CosmosClient
 
3
 
4
  # Load and save query files
5
  def load_query(filename):
 
13
  # Streamlit UI
14
  st.title("Azure Cosmos DB Explorer πŸ‘½")
15
 
16
+ # Default URI and KEY (You can set these values in code)
17
+ default_account_uri = "Your Default Cosmos DB URI Here"
18
+ default_account_key = "Your Default Cosmos DB Key Here"
19
 
20
  client = None
21
 
22
  # Connection Details Expander
23
  with st.expander("Connect 🌍"):
24
+ account_uri = st.text_input("Account URI:", default_account_uri)
25
+ account_key = st.text_input("Account Key:", default_account_key, type="password")
26
  database_name = st.text_input("Database Name:", "")
27
  container_name = st.text_input("Container Name:", "")
28
  if st.button("Connect"):
29
  try:
30
+ client = CosmosClient(account_uri, credential=account_key)
31
  database_client = client.get_database_client(database_name)
32
  container_client = database_client.get_container_client(container_name)
33
  st.success("Connected successfully! πŸŽ‰")
 
72
  st.markdown("""
73
  ## Instructions to Run this App:
74
 
75
+ 1. **Install Packages**: If you haven't, install the required Python packages: