Python Driver for ArangoDB
Project description
Python-Arango
Python driver for ArangoDB, a scalable multi-model database natively supporting documents, graphs and search.
Requirements
- ArangoDB version 3.7+
- Python version 3.7+
Installation
pip install python-arango --upgrade
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]
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.
edges = 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.
edges.insert({"_from": "students/01", "_to": "lectures/MAT101"})
edges.insert({"_from": "students/01", "_to": "lectures/STA101"})
edges.insert({"_from": "students/01", "_to": "lectures/CSC101"})
edges.insert({"_from": "students/02", "_to": "lectures/MAT101"})
edges.insert({"_from": "students/02", "_to": "lectures/STA101"})
edges.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"
)
Please see the documentation for more details.
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
python-arango-7.5.6.tar.gz
(133.5 kB
view details)
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
python_arango-7.5.6-py3-none-any.whl
(101.2 kB
view details)
File details
Details for the file python-arango-7.5.6.tar.gz.
File metadata
- Download URL: python-arango-7.5.6.tar.gz
- Upload date:
- Size: 133.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa277ebeffc1eb43c7ad62a338fd2f3d10ab130bc75b5c4bf358076d8268ea1b
|
|
| MD5 |
8f4f19b615219a1d2bd929e64d24831c
|
|
| BLAKE2b-256 |
08039d89dc65acec6c3dc1475db467eae66c7cf02bb4da7f84c6289d42055c02
|
File details
Details for the file python_arango-7.5.6-py3-none-any.whl.
File metadata
- Download URL: python_arango-7.5.6-py3-none-any.whl
- Upload date:
- Size: 101.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42d4a55fc0aec3904db9b1f48daad7ef0d4c19eb8b75296ff9b1f2081512401b
|
|
| MD5 |
efb6aa3b1f910dd801330d3e956d0183
|
|
| BLAKE2b-256 |
5f27864454c5f02a5d8a661f7bede471b1f0e2bf04d9418c04051fb18f36676c
|