Collections

A collection contains documents. It is uniquely identified by its name which must consist only of hyphen, underscore and alphanumeric characters. There are three types of collections in python-arango:

  • Standard Collection: contains regular documents.

  • Vertex Collection: contains vertex documents for graphs. See here for more details.

  • Edge Collection: contains edge documents for graphs. See here for more details.

Here is an example showing how you can manage standard collections:

from arango import ArangoClient

# Initialize the ArangoDB client.
client = ArangoClient()

# Connect to "test" database as root user.
db = client.db('test', username='root', password='passwd')

# List all collections in the database.
db.collections()

# Create a new collection named "students" if it does not exist.
# This returns an API wrapper for "students" collection.
if db.has_collection('students'):
    students = db.collection('students')
else:
    students = db.create_collection('students')

# Retrieve collection properties.
students.name
students.db_name
students.properties()
students.revision()
students.statistics()
students.checksum()
students.count()

# Perform various operations.
students.load()
students.unload()
students.truncate()
students.configure()

# Delete the collection.
db.delete_collection('students')

See StandardDatabase and StandardCollection for API specification.