dual_window / db.py
Huanzhi (Hans) Mao
init
4d1746c
raw
history blame
373 Bytes
from pymongo import MongoClient
from pymongo.server_api import ServerApi
import os
uri = os.getenv('DATABASE_URL').strip()
cluster = MongoClient(uri, server_api=ServerApi('1'))
try:
cluster.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
except Exception as e:
print(e)
db = cluster["test"]
collection = db["test"]