muhammadnoman76's picture
update
75e2b6c
raw
history blame contribute delete
465 Bytes
import os
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
uri = os.getenv('MONGO_URI')
mongo_uri = os.getenv('MONGO_URI')
if not mongo_uri:
raise ValueError("MONGO_URI environment variable is not set")
def get_db():
client = MongoClient(uri, server_api=ServerApi('1'))
try:
client.admin.command('ping')
except Exception as e:
print(e)
return client.get_database("dermai")
db = get_db()