-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
30 lines (22 loc) · 756 Bytes
/
database.py
File metadata and controls
30 lines (22 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from pymongo.mongo_client import MongoClient
from pymongo.server_api import ServerApi
uri = os.getenv("MONGODB_URI")
# Create a new client and connect to the server
client = MongoClient(uri, server_api=ServerApi('1'))
# Send a ping to confirm a successful connection
try:
client.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
except Exception as e:
print(e)
# client = MongoClient("mongodb://localhost:27017")
db = client.market_research
def insert_company_info(data):
db.company_info.insert_one(data)
def insert_use_case(data):
db.use_cases.insert_one(data)
def insert_datasets(data):
db.datasets.insert_one(data)
def log_request(data):
db.logs.insert_one(data)