File size: 361 Bytes
f70d907
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import streamlit as st
import pymongo
import os

@st.cache_resource
def init_conn():
    uri = os.getenv('MONGO_URI')
    if not uri:
        uri = st.secrets['mongo_uri']
    client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
    db = client["NFL_Database"]
    return db

# Initialize the database connection
db = init_conn()