我正在try 获取mongo数据库中存在的一些ID,代码如下:
client = MongoClient('xx.xx.xx.xx', xxx)
db = client.test_database
db = client['...']
collection = db.test_collection
collection = db["..."]
for cursor in collection.find({ "$and" : [{ "followers" : { "$gt" : 2000 } }, { "followers" : { "$lt" : 3000 } }, { "list_followers" : { "$exists" : False } }] }):
print cursor['screenname']
print cursor['_id']['uid']
id = cursor['_id']['uid']
然而,过了一会儿,我收到了这个错误:
皮Mongo .错误.CursorNotFound:光标id"…"在服务器上无效.
我找到了这个article,它指的是那个问题.然而,我不清楚该采取哪种解决方案.可以用find().batch_size(30)
吗?上面的命令具体是做什么的?我可以使用batch_size
获取所有数据库ID吗?