I need your help. I am fetching data from a mongoDb server using Python. While fetching data I encounter an error.
drivers = mongodb_global('drivers')
filter_col = {
"created": 1,
"updated": 1,
"_id": 1,
"name": 1,
"birthday": 1,
"id_expiry": 1,
"license_expiry": 1
}
data = drivers.find({}, filter_col)
driver_lst = []
for item in data:
print(item)
"return EPOCH_NAIVE + datetime.timedelta(seconds=seconds,
bson.errors.InvalidBSON: date value out of range"
I have searched everywhere but couldn’t find a solution. the problem is that I am getting an error at the db.find({}) stage, so I am unable to handle this error in the later stages of the pipeline. Could you please guide me, how to handle this error?
I have tried to solve this error but not solved.
2
Answers
Try to handle the exception like:
This is so strange.
Your code above try to simply return documents with specific columns, so that should work even if there is no validity check of the date column. I have tried the same code on the following collection and it does work :
It returns this: