Skip to main content

Python Driver for ArangoDB

Project description

https://cloud.githubusercontent.com/assets/2701938/18018900/668e15d2-6ba7-11e6-85a9-7997b3c6218a.png

Travis Build Status Documentation Status Package Version Python Versions Test Coverage Issues Open MIT License

Welcome to the GitHub page for python-arango, a Python driver for ArangoDB.

Announcements

  • Python-arango version 4.0.0 is now out!
  • Please see the releases page for details on latest updates.

Features

  • Clean Pythonic interface.
  • Lightweight.
  • High ArangoDB REST API coverage.

Compatibility

  • Python versions 2.7, 3.4, 3.5 and 3.6 are supported.
  • Python-arango 4.x supports ArangoDB 3.3+ (recommended).
  • Python-arango 3.x supports ArangoDB 3.0 ~ 3.2 only.
  • Python-arango 2.x supports ArangoDB 1.x ~ 2.x only.

Installation

To install a stable version from PyPi:

~$ pip install python-arango

To install the latest version directly from GitHub:

~$ pip install -e git+git@github.com:joowani/python-arango.git@master#egg=python-arango

You may need to use sudo depending on your environment.

Getting Started

Here is a simple usage example:

from arango import ArangoClient

# Initialize the client for ArangoDB.
client = ArangoClient(protocol='http', host='localhost', port=8529)

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

# Create a new database named "test".
sys_db.create_database('test')

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

# Create a new collection named "students".
students = db.create_collection('students')

# Add a hash index to the collection.
students.add_hash_index(fields=['name'], unique=True)

# Insert new documents into the collection.
students.insert({'name': 'jane', 'age': 39})
students.insert({'name': 'josh', 'age': 18})
students.insert({'name': 'judy', 'age': 21})

# Execute an AQL query and iterate through the result cursor.
cursor = db.aql.execute('FOR doc IN students RETURN doc')
student_names = [document['name'] for document in cursor]

Here is another example with graphs:

from arango import ArangoClient

# Initialize the client for ArangoDB.
client = ArangoClient(protocol='http', host='localhost', port=8529)

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

# Create a new graph named "school".
graph = db.create_graph('school')

# Create vertex collections for the graph.
students = graph.create_vertex_collection('students')
lectures = graph.create_vertex_collection('lectures')

# Create an edge definition (relation) for the graph.
register = graph.create_edge_definition(
    edge_collection='register',
    from_vertex_collections=['students'],
    to_vertex_collections=['lectures']
)

# Insert vertex documents into "students" (from) vertex collection.
students.insert({'_key': '01', 'full_name': 'Anna Smith'})
students.insert({'_key': '02', 'full_name': 'Jake Clark'})
students.insert({'_key': '03', 'full_name': 'Lisa Jones'})

# Insert vertex documents into "lectures" (to) vertex collection.
lectures.insert({'_key': 'MAT101', 'title': 'Calculus'})
lectures.insert({'_key': 'STA101', 'title': 'Statistics'})
lectures.insert({'_key': 'CSC101', 'title': 'Algorithms'})

# Insert edge documents into "register" edge collection.
register.insert({'_from': 'students/01', '_to': 'lectures/MAT101'})
register.insert({'_from': 'students/01', '_to': 'lectures/STA101'})
register.insert({'_from': 'students/01', '_to': 'lectures/CSC101'})
register.insert({'_from': 'students/02', '_to': 'lectures/MAT101'})
register.insert({'_from': 'students/02', '_to': 'lectures/STA101'})
register.insert({'_from': 'students/03', '_to': 'lectures/CSC101'})

# Traverse the graph in outbound direction, breadth-first.
result = graph.traverse(
    start_vertex='students/01',
    direction='outbound',
    strategy='breadthfirst'
)

Check out the documentation for more details.

Contributing

Please take a look at this page before submitting a pull request. Thanks!

Project details


Release history Release notifications

This version
History Node

4.1.0

History Node

4.0.1

History Node

4.0.0

History Node

3.12.1

History Node

3.11.0

History Node

3.10.1

History Node

3.10.0

History Node

3.9.0

History Node

3.8.0

History Node

3.7.0

History Node

3.6.0

History Node

3.5.0

History Node

3.4.1

History Node

3.4.0

History Node

3.3.0

History Node

3.2.2

History Node

3.2.1

History Node

3.2.0

History Node

3.1.0

History Node

3.0.0

History Node

2.2.0

History Node

2.1.0

History Node

2.0.0

History Node

1.4.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
python-arango-4.1.0.tar.gz (53.3 kB) Copy SHA256 hash SHA256 Source None May 16, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page