-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Environment:Pymongo 3.2.2
Python 3.4 Anaconda
MongoDB 3.0.6
I am trying to do a simple insert. Here is my code:
>>> from pymongo import MongoClient
>>> client = MongoClient(connect=False)
>>> client["mydb"]
Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'mydb')
>>> db = client["mydb"]
>>> db["mycollection"]
Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'mydb'), 'mycollection')
>>> book = {}
>>> book["title"] = "AnyBook"
>>> book["Author"] = "AnyAuthor"
>>> collection.insert(book)
Traceback (most recent call last):
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 8] nodename nor servname provided, or not known
Additionally, I have tried it without passing any parameters, i.e., MongoClient()
and have also pip installed version pymongo version2. Neither which has worked. No one on stackoverflow seems to know.