0

I have installed mongo-db from the Jupyter notebook using !pip install pymongo.

Now how to start mongodb. Is there any way to start mongodb through Juyter Notebook.

from pymongo import MongoClient
client = MongoClient()
#print (client)
#client = MongoClient('mongodb://localhost:27017')
db  = client['test-database']
#print (db)
courses = db.courses
#print (courses)
course = {
    'author':'Mak',
    'course':'Data',
    'price': 100,
    'rating':5
    }
result = courses.insert_one(course)

I am getting ServerSelectionTimeoutError Traceback (most recent call last) since there is no mongodb started

  • try this once : Step 1: 'import pymongo'; then step 2: 'client = pymongo.MongoClient("mongodb://localhost")' – dev_user Aug 13 '19 at 06:17
  • same error I got –  Aug 13 '19 at 06:26
  • open your mongodb connections & check whether it is successfully connected or not (click on the test button;then you can see one green tick if it is successfully connected ) – dev_user Aug 13 '19 at 06:34

2 Answers2

1

pymongo is a client and you need a server too.

From the pymongo tutorial:

enter image description here

https://api.mongodb.com/python/current/tutorial.html

matcheek
  • 4,887
  • 9
  • 42
  • 73
0

Thanks @match

Install server before using it

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

go to folder where you installed mongodb

C:\Program Files\MongoDB\Server\4.0\bin>

start mongo.exe