I have a problem connecting to Mongo. Would appreciate help.. Thanks
client =MongoClient("mongodb+srv://srdht:srdht@srddataset.2htbr.mongodb.net/dbImages?retryWrites=true&w=majority",ssl=True,ssl_cert_reqs='CERT_NONE')
db=client.get_database('dbImages')
records = db.atopic
records.count_documents({})
new_student = {
'name': 'ram',
'roll_no': 321,
'branch': 'it'
}
records.insert_one(new_student)
new_students = [
{
'name': 'alex',
'roll_no': 320,
'branch': 'it'
},
{
'name': 'john',
'roll_no': 30,
'branch': 'ece'
}
]
records.insert_many(new_students)
and error:
Traceback (most recent call last):
File "C:/Users/student/Documents/GitHub/SRD/imageProcessing.py", line 24, in <module>
**client =MongoClient("mongodb+srv://srdht:srdht@srddataset.2htbr.mongodb.net/dbImages?retryWrites=true&w=majority",ssl=True,ssl_cert_reqs='CERT_NONE')**
File "C:\Users\student\.windows-build-tools\python27\lib\site-packages\pymongo\mongo_client.py", line 672, in __init__
connect_timeout=timeout)
File "C:\Users\student\.windows-build-tools\python27\lib\site-packages\pymongo\uri_parser.py", line 453, in parse_uri
**'%s -m pip install "pymongo[srv]"' % (python_path))
pymongo.errors.ConfigurationError: The "dnspython" module must be installed to use mongodb+srv:// URIs. To fix this error install pymongo with the srv extra:
C:\Users\student\.windows-build-tools\python27\python.exe -m pip install "pymongo[srv]"**
You need to install the dnspython, try this command to install it:
python -m pip install pymongo[srv]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.