pythonarangodbpyarango

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? I could not find how to do this in the documentation. My collection has name="testCollection"

Thanks!


Solution

  • 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