Junaidb commited on
Commit
9491b2c
·
verified ·
1 Parent(s): 5eb936a

Create mongodbconnection.py

Browse files
Files changed (1) hide show
  1. components/mongodbconnection.py +11 -0
components/mongodbconnection.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pymongo.mongo_client import MongoClient
2
+ from pymongo.server_api import ServerApi
3
+ uri = "mongodb+srv://junaid:junaid@cluster0.0ec6y.mongodb.net/?appName=Cluster0"
4
+ client = MongoClient(uri, server_api=ServerApi('1'))
5
+ try:
6
+ client.admin.command('ping')
7
+ print("Pinged your deployment. You successfully connected to MongoDB!")
8
+ except Exception as e:
9
+ print(e)
10
+ def provideClient():
11
+ return client