【问题标题】:gridfs How to read chunk in pythongridfs如何在python中读取块
【发布时间】:2021-10-27 06:41:09
【问题描述】:
fs = gridfs.GridFS(client[db_name])
fs.find_one(file_id).readchunk()

如何读取网格的所有块?当我在 for 循环中使用 readchunk 函数时,它只会继续返回我的第一个网格块。

gridfs的api文档:https://pymongo.readthedocs.io/en/stable/api/gridfs/grid_file.html#gridfs.grid_file.GridOut

【问题讨论】:

    标签: python mongodb pymongo gridfs


    【解决方案1】:

    块在 GridFS 实现内部。您应该使用readreadline

    【讨论】:

    • 感谢您的回答。但是当我使用read() 时,程序很快就会因为内存不足而关闭。仅供参考:我的文件大约 64mb 大。对于readline(),我可以举一些如何使用它的例子吗?
    • grid_out.seek(pos=0); grid_out.readline(); grid_out.seek(pos=grid_out.tell()); grid_out.readline(); 它有效!谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 2022-01-25
    • 1970-01-01
    相关资源
    最近更新 更多