Junaidb commited on
Commit
da39ec6
·
verified ·
1 Parent(s): 443a7c7

Create components/dbconnection.py

Browse files
Files changed (1) hide show
  1. components/dbconnection.py +18 -0
components/dbconnection.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pymongo import MongoClient
2
+ from pymongo.server_api import ServerApi
3
+
4
+ # The connection URI
5
+ uri = "mongodb+srv://junaid:junaid@cluster0.0ec6y.mongodb.net/?appName=Cluster0"
6
+
7
+ # Create a new client and connect to the server
8
+ # Note: server_api is optional but used here to match your Node.js 'ServerApiVersion.v1'
9
+ client = MongoClient(uri, server_api=ServerApi('1'))
10
+
11
+ def provide_client():
12
+ """
13
+ Returns the MongoDB client instance.
14
+ """
15
+ return client
16
+
17
+ # Example of how to export/use in another file:
18
+ # from your_filename import provide_client