-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMongoDB.py
More file actions
115 lines (59 loc) · 1.97 KB
/
Copy pathMongoDB.py
File metadata and controls
115 lines (59 loc) · 1.97 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python
# coding: utf-8
# In[1]:
get_ipython().system('pip install pymongo')
from pymongo import MongoClient
import csv
get_ipython().system('pip install dnspython')
# In[7]:
def get_database():
from pymongo import MongoClient
import pymongo
CONNECTION_STRING = "mongodb+srv://zakdemir:Ceng476@cluster0.ez5sn.mongodb.net/?retryWrites=true&w=majority"
client = MongoClient(CONNECTION_STRING)
# In[10]:
import pymongo
from pymongo import MongoClient
client = pymongo.MongoClient("mongodb+srv://zakdemir:Ceng476@cluster0.ez5sn.mongodb.net/?retryWrites=true&w=majority")
# In[13]:
from pymongo import MongoClient
client=MongoClient()
# Connect with the portnumber and host
client = MongoClient("mongodb://localhost:8888/")
# Access database
mydatabase = client['database']
# Access collection of the database
mycollection=mydatabase['wine']
# In[17]:
print(mydatabase.wine.count({quality: '5'}))
# In[22]:
from pymongo import MongoClient
client=MongoClient()
client = MongoClient("mongodb://localhost:8888/")
mydatabase = client['database']
print(mydatabase.list_collection_names())
# In[23]:
from pymongo import MongoClient
import pymongo
# Provide the mongodb atlas url to connect python to mongodb using pymongo
CONNECTION_STRING = "mongodb+srv://zakdemir:Ceng476@cluster0.ez5sn.mongodb.net/database"
# Create a connection using MongoClient. You can import MongoClient or use pymongo.MongoClient
from pymongo import MongoClient
client = MongoClient(CONNECTION_STRING)
# In[24]:
get_ipython().system('pip install dnspython')
# In[ ]:
get_ipython().system('pip install --upgrade pip')
# In[14]:
import pymongo
import pprint
import json
import pprint
import warnings
warnings.filterwarnings('ignore')
client = pymongo.MongoClient("mongodb+srv://zakdemir:Ceng476@cluster0.ez5sn.mongodb.net/?retryWrites=true&w=majority")
dbname = client['database']
mycollection = dbname["wine"]
for i in mycollection.find():
print(1)
# In[ ]: