问题标签 [pymongo]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - The best way to get embedded documents in pymongo?
I has in MongoDB documents like this:
You can see that the key "pages" is a array with other documents. Now I can query this document with the name of a page and I will get the full document with all pages and other information. I use in python directly pymongo to query the document but now I don't know what the best way is to get a page from the array pages. I think something like this:
But is this the best way to get a singe page or general a embedded document? All tipps or code snippets are welcome.
Thanks! Jarus
mercurial - 如何在 Snow Leopard 10.6.6 上默认禁用 easy_install 或 pip 构建 ppc?
由于我安装了 Xcode 4 并且似乎 xcode 4 无法再构建 ppc 二进制文件,因此很多 python 包(尤其是 mercurial pymongo 等)无法构建并抱怨没有为 ppc 架构安装“as” . 有没有办法从构建 ppc 中禁用 pip 或 easy_install?
我有来自 Mac App Store 的雪豹 10.6.6、Xcode 4。(Xcode 3 没有安装,我不想要重复的开发工具)。
谢谢!
django - 偶尔出现“ConnectionError:无法连接到数据库”到 mongo
我们目前正在测试一个使用 MongoEngine 作为持久层的基于 django 的项目。MongoEngine 基于 pymongo,我们使用的是 1.6 版,我们正在运行 mongo 的单实例设置。
我们注意到,偶尔,大约 5 分钟,无法建立与 mongo 实例的连接。有没有人遇到过这样的行为?关于如何提高可靠性的任何提示?
python - pymongo 中的快速或批量更新
如何在 pymongo 中进行批量更新?我想更新一堆条目,一次做一个非常慢。
几乎相同的问题的答案在这里:在 MongoDB 中批量更新/更新?
接受的答案实际上并没有回答问题。它只是提供了一个到 mongo CLI 的链接以进行导入/导出。
我也愿意向某人解释为什么不可能进行批量 upsert/不是最佳实践,但请解释此类问题的首选解决方案是什么。
python - 在 Python 中执行 MongoDb 语句
我有一个在 Python 中运行的网络服务器。他正在从一些应用程序中获取一些数据,并且需要将这些数据存储在 MongoDB 中。我的 MongoDB 已分片。现在我想让我的网络服务器知道 MongoDB 有多少 Shards。目前,他从 cfg 文件中读取此信息。MongoDb 中有一个名为 printshardingstatus 的语句,您可以在其中查看所有分片。所以我试图从我的 Pythonserver 调用这个语句。但是好像不行。我在Pymongo API中没有找到这样的功能。
所以我的问题是,是否有机会在 Python 中运行 MongoDB 语句,以便直接在 MongoDB 中传递和执行?
python - 如何在 MongoKit 中关闭光标
我正在使用 MongoKit 对大量数据执行迭代。
在此过程中,我的光标变得无效,我得到
OperationFailure: cursor id '369397057360964334' not valid at server
我在邮件列表中读到我可以将参数传递timeout=False
给.find()
方法,但PyMongo 常见问题解答说我必须自己负责关闭光标。
但是我没有在 MongoKit 中找到方法。
我是否需要自己关闭光标,如果是 - 我该怎么做?
mapreduce - pymongo mapreduce db 断言失败
我刚刚开始使用 mongo 和 map/reduce,并且在使用 pymongo 时遇到了以下错误,而直接使用 mongo 命令行时我没有得到(我意识到有一个与此类似的问题,但我的似乎更基本)。
我直接使用 pymongo 文档中的示例:http: //api.mongodb.org/python/1.3%2B/examples/map_reduce.html
这给了我以下错误:
但是,在 mongo 中定义 map/reduce 函数并运行以下命令是可行的:
决定性的区别似乎是 {out:{inline:1}} 选项。有没有办法在 pymongo 中调用它?
谢谢,
亚当。
mongodb - 安全插入的 Pymongo 权限问题
我有一个正在运行的 Mongo 实例,可以成功连接到数据库并进行身份验证。我可以使用collection.insert([list of records to insert])
.
但是,当我添加safe=True
以确保插入记录时,如以下命令,我收到以下错误,这似乎是权限问题。我怎样才能解决这个问题?
mongodb - Mongo 在数据查找期间找不到 master
我正在使用 pymongo 运行大型数据更新。要运行更新,使用 找到单个记录collection.find_one(unique criteria)
,进行更改,批量更新,最后使用块发送db.collection.save([long list of records to save])
在我的本地机器(运行 1.6.3)上,导入工作正常。
在比本地机器快得多的远程服务器(运行 1.6.0)上,我可以很好地完成部分插入,但是在查找原始记录时会突然出现以下错误:
我可以通过的记录数量有所不同,但不是随机的。
起初我以为我遇到了连接限制。在每次记录查找后,我开始手动关闭连接:
哪个没有解决问题。我在正确的轨道上吗?
python - PyMongo vs MongoEngine for Django
对于我的一个项目,我更喜欢使用Django+Mongo。
为什么我应该使用MongoEngine,而不仅仅是PyMongo?有什么优势?使用 PyMongo 查询会给出已经是对象的结果,不是吗?那么MongoEngine的目的是什么?