I was trying to create a project in pycharm which uses MongoDB and Pymongo. But I encountered the following error :
Traceback (most recent call last):
File "C:/Users/IngeniousAmbivert/PycharmProjects/terminal_blog/app.py", line 6, in <module>
client = pymongo.MongoClient(uri)
File "C:\Users\IngeniousAmbivert\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pymongo\mongo_client.py", line 400, in __init__"%s" % (entity[:idx],))
pymongo.errors.InvalidURI: Invalid URI scheme: mongodb
For the following code :
import pymongo
uri = " mongodb://127.0.0.1:27017"
client = pymongo.MongoClient(uri)
database = client['stack']
collection = database['students']
students = collection.find({})
print(students)
Any help will be appreciated .
Okay . I figured it out . Just needed to remove the space
uri = " mongodb://127.0.0.1:27017/" = Error
uri = "mongodb://127.0.0.1:27017" = No Error
Output :
<pymongo.cursor.Cursor object at 0x038B58D0>
Damn ! I keep forgetting Python is a space sensitive programming language
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With