I am having some issues connecting to my database on MongoDB. I am using mongoengine library to connect to the DB. I am also using ATLAS. Whenever I try to run my project it keeps showing “Exception has occurred: ServerSelectionTimeoutError” then show [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate If anyone could assist me? Or any
Tag: mongodb
scrapy internal links + pipeline and mongodb collection relationships
I am watching videos and reading some articles about how scrapy works with python and inserting to mongodb. Then two questions popped up which either I am not googling with the correct keywords or just couldn’t find the answer. Anyways, let me take example on this tutorial site https://blog.scrapinghub.com to scrape blog posts. I know we can get things like
MongoDB/Python – Date in collection (to use for query)
I just started using mongoDB (Version 3.6.8) today, and I like it. I was reading that it should be possible to have a date object directly in the database, but I can’t get it to work. Also I was wondering if it is the best solution or if I should just store my dates as “Epoch millis” instead? I am
How to parse and read “_id” field from and to a pydantic model?
I am trying to parse MongoDB data to a pydantic schema but fail to read its _id field which seem to just disappear from the schema. The issue is definitely related to the underscore in front of the object attribute. I can’t change _id field name since that would imply not parsing the field at all. Please find below the
How to get keys of nested mongodb documents
I have data like this, I need all the keys from this mongodb collection like property1,property2 etc. I tried Answer You can use $objectToArray to read object keys dynamically and then run $reduce with $concatArrays to merge the results: Output: Mongo playground
How to import JSON file to MongoDB using Python
I have this JSON file, currencies.json: And this connection in Python: My db name is countries_db with the currency collection. Is there a way to import the file to the db using python? Thanks for your help. Answer You can read data from file and insert it into collection using insert_one method:
pymongo auth failed in python script
I have installed mongodb and enabled auth. and its working find. I can connect it from remote notebook using robomongo application: and We can connect from server shell locally using: Everything works fine, but when we try it using pymongo api. authentications failed. below is the python code: Tools used: Error trace: Solution: problem was with database name, following code
How can I copy one collection from MongoDB using pymongo and paste to another empty collection?
I want to copy full collection (e.g. name ‘home’). Then do some changes in the ‘home’ collection or remove doc inside it (not a collection). And then replace changed ‘home’ collection to its default state from item 1. I do next: But the collection is empty. Answer The problem with your code example is that find() returns a database cursor
get mongodb “_id” in django template
My question is related to this question. I am trying to display all the _id of mongo database in django template from last 2 days but unable to get it. This is the error: This is the code I am trying: views.py product.html Though, I tried changing the name to static, cache etc, but still no luck. Answer template tag
How to run MongoDB commands with pymongo?
I need to see list of connections to MongodDB. I know how to do it in mongo console: Now I want to do the same using pymongo. I tried following and it didn’t work: After that I used db.command() in various combinations trying to pass “db.currentOp(true)” to it without success. How to do it properly? The question is how to