Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
18 |
-
|
19 |
-
|
20 |
|
21 |
client = None
|
22 |
|
23 |
# Connection Details Expander
|
24 |
with st.expander("Connect π"):
|
25 |
-
st.
|
|
|
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(
|
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. **
|
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:
|
|
|
|
|
|
|
|