Spaces:
Running
Running
James McCool
commited on
Commit
·
15461f8
1
Parent(s):
a5375cb
instituting database.py
Browse files- src/database.py +15 -0
- src/streamlit_app.py +1 -15
src/database.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pymongo
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
@st.cache_resource
|
| 6 |
+
def init_conn():
|
| 7 |
+
uri = os.getenv('MONGO_URI')
|
| 8 |
+
if not uri:
|
| 9 |
+
uri = st.secrets['mongo_uri']
|
| 10 |
+
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
| 11 |
+
db = client["NFL_Database"]
|
| 12 |
+
|
| 13 |
+
return db
|
| 14 |
+
|
| 15 |
+
db = init_conn()
|
src/streamlit_app.py
CHANGED
|
@@ -1,25 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
-
import
|
| 5 |
-
import re
|
| 6 |
-
import os
|
| 7 |
from itertools import combinations
|
| 8 |
|
| 9 |
st.set_page_config(layout="wide")
|
| 10 |
|
| 11 |
-
@st.cache_resource
|
| 12 |
-
def init_conn():
|
| 13 |
-
uri = os.getenv('MONGO_URI')
|
| 14 |
-
if not uri:
|
| 15 |
-
uri = st.secrets['mongo_uri']
|
| 16 |
-
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
| 17 |
-
db = client["NFL_Database"]
|
| 18 |
-
|
| 19 |
-
return db
|
| 20 |
-
|
| 21 |
-
db = init_conn()
|
| 22 |
-
|
| 23 |
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
| 24 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
| 25 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
+
from database import db
|
|
|
|
|
|
|
| 5 |
from itertools import combinations
|
| 6 |
|
| 7 |
st.set_page_config(layout="wide")
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
| 10 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
| 11 |
|