-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kosarevskiydp
committed
Dec 17, 2021
1 parent
70db1e4
commit d7d0bfb
Showing
5 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import streamlit as st | ||
import pymongo | ||
|
||
|
||
# Pull data from the collection. | ||
# Uses st.cache to only rerun when the query changes or after 10 min. | ||
# @st.cache(ttl=600) | ||
def get_data(client): | ||
db = client.sample_analytics | ||
items = db.customers.find() | ||
items = list(items) # make hashable for st.cache | ||
return items | ||
|
||
|
||
def main(): | ||
st.subheader("Mongo") | ||
|
||
# Initialize connection. | ||
client = pymongo.MongoClient(**st.secrets["mongo"]) | ||
|
||
# test_db = client.db.test | ||
# st.write(test_db) | ||
# test_collection = test_db.test_collection | ||
# st.write(test_collection) | ||
# st.write(test_collection.find_one()) | ||
|
||
db = client.sample_analytics | ||
st.write(db) | ||
st.write(db.customers.find_one()) | ||
|
||
# items = get_data(client) | ||
|
||
# Print results. | ||
# for item in items: | ||
# st.write(item) | ||
# st.write(f"{item['name']} has a :{item['pet']}:") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters