I connected the database with mongoClient from pymongo. I made a find() query but I can't read the result inside the cursor and I don't know why. Before I made this query from my local database and it worked, now I move all the code on a ubuntu server and the same code doesn't work anymore.
I tried this but it doesn't work on the server. On the local environment, it works
import json
import requests
from pymongo import MongoClient
client = MongoClient('mongodb://IP_ADDRESS/')
db=client.mydb
mycol = mydb["mycollection"]
array = []
for x in mycol.find():
array.append(x)
print(array)
I also tried this but the response is a cursor and I don't know how to read this
import json
import requests
from pymongo import MongoClient
client = MongoClient('mongodb://IP_ADDRESS/')
db=client.mydb
mycol = mydb["mycollection"]
x = mycol.find()
print(x)
this is the output I obtained:
<pymongo.cursor.Cursor object at 0x7fa7bd016c10>
my expected value is something like this:
{ "_id" : ObjectId("5d47f749fa8ca433e0d58b5f"), "value1" : "result1", "value2" : "result2", "value3" : "result3"}