Python Driver for ArangoDB
Project description
Welcome to the GitHub page for python-arango, a Python driver for ArangoDB.
Compatibility
Python versions 3.5+ are supported
Python-arango 6.x supports ArangoDB 3.7+
Python-arango 5.x supports ArangoDB 3.5 ~ 3.6
Python-arango 4.x supports ArangoDB 3.3 ~ 3.4
Python-arango 3.x supports ArangoDB 3.0 ~ 3.2
Python-arango 2.x supports ArangoDB 1.x ~ 2.x
Announcements
Python-arango is dropping support for Python 2.7 from version 6.0.0.
Check out project aioarangodb, fork of python-arango using asyncio.
Installation
To install a stable version from PyPi:
~$ pip install python-arango
To install the latest version from GitHub:
~$ pip install -e git+git@github.com:joowani/python-arango.git@master#egg=python-arango
To install experimental version from GitHub:
~$ pip install -e git+git@github.com:joowani/python-arango.git@dev#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(hosts='http://localhost: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(hosts='http://localhost: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 information.
Contributing
Please take a look at this page before submitting a pull request. Thanks!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python-arango-6.1.0.tar.gz.
File metadata
- Download URL: python-arango-6.1.0.tar.gz
- Upload date:
- Size: 85.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04dbb017945105925c01d05ac98a62d718d29586cf39ef85ae3a44f032923b1c
|
|
| MD5 |
7f4e09dff6a3b6237519dd7228152301
|
|
| BLAKE2b-256 |
f8396f0670079e3c9d07582377f4c0ede17393620e1335af9afc5a4882f1c2fe
|
File details
Details for the file python_arango-6.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: python_arango-6.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 92.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca31ceb555ff7c9671ada61c6a81abdcd24b308e76a27d91398a98320f9b27db
|
|
| MD5 |
620c25dc5cebe2cf074ee442d0d4228c
|
|
| BLAKE2b-256 |
aa68a4ea8cf46d528755ebfb925cd899ed666d47d9d3db38640968d23ad8a4fb
|