Python Mongodb Error

less than 1 minute read

  1. mongodb cursor id not valid error stackoverflow

解决方案

1、设置no_cursor_timeout = True,永不超时,游标连接不会主动关闭,需要手动关闭

demos = db['demo'].find({},{"_id": 0},no_cursor_timeout = True)

for cursor in demos:

        do_something()

demo.close() # 关闭游标

2、设置batch_size返回文档数,默认应该是20个文档(记不清了233333),可以设置小一些

#每次只返回一个文档

demos = db['demo'].find({},{"_id": 0}).batch_size(1)

for cursor in demos:

        do_something()

注意:这种方法仍然会出现可能超过10分钟任然没有返回,比如你在do_something里进行一些十分耗时的操作,具体采用哪种方法按实际情况而定 3.mongodump -h localhost –port 27017 -d paper -o /home/vincent/db/

mmongorestore -d paper –drop /home/vincent/db/

C:\Users\yukaizhao>mysql.exe –host=localhost –user=root –password=root –port=3306 –default-character-set=utf8 –omments –database=outofmemory < “E:\outofmemory\data\dumps\oom_13010104.sql”

4.java.nio.file.AccessDeniedException: Ubuntu check file access ls -a chown -R vincent:vincent file

Categories: , , , ,

Updated:

Leave a Comment