[英]How do I get a collection object in pyarango?
I can get a database object with the code: 我可以使用以下代码获取数据库对象:
import pyArango.database as DAT
db = DAT.Database(connection, dbName)
and according to the documentation, I can get a collection with the code: 根据文档,我可以使用以下代码获得集合:
import pyArango.collection as COL
collection = COL.Collection(database, jsonData)
How do I format jsonData to return my collection? 如何格式化jsonData以返回我的集合? I could not find how to do this in the documentation.
我在文档中找不到如何执行此操作。 My collection has
name="testCollection"
我的收藏
name="testCollection"
Thanks! 谢谢!
I believe I figured it out. 我相信我知道了。 Collections should be instantiated by the database object, which is instantiated by the connection object.
集合应该由数据库对象实例化,而数据库对象由连接对象实例化。
import pyArango.connection as CON
db = CON.Connection(username=<user>, password=<password>).databases[<DB name>]
collection = db.collections['testCollection']
This works as intended, and returns: 这将按预期工作,并返回:
ArangoDB collection name: testCollection, id: 14217, type: document, status: loaded
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.