GithubHelp home page GithubHelp logo

kumsumit / async-arango Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arangodb/python-arango

0.0 0.0 0.0 1.14 MB

Asynchronous Python Driver for ArangoDB

Home Page: https://docs.python-arango.com

License: MIT License

Python 100.00%

async-arango's Introduction

Logo

CodeCov PyPI version GitHub license Python version

aioarango

Asynchronous python driver for ArangoDB, a scalable multi-model database natively supporting documents, graphs and search.

This project is forked from python-arango. The only change is support for asynchronous API including tests. The current version (1.0.0) fully corresponds to python-arango 7.2.0.

Requirements

  • ArangoDB version 3.7+
  • Python version 3.7+

Installation

pip install aioarango

Getting Started

Here is a simple usage example:

from aioarango import ArangoClient

# Initialize the client for ArangoDB.
client = ArangoClient(hosts="http://localhost:8529")

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

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

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

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

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

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

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

Another example with graphs:

from aioarango import ArangoClient

# Initialize the client for ArangoDB.
client = ArangoClient(hosts="http://localhost:8529")

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

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

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

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

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

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

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

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

Please see the documentation for more details.

async-arango's People

Contributors

153957 avatar amahanna avatar aquamatthias avatar avinash240 avatar carlverge avatar coderjayo avatar cw00dw0rd avatar darkheir avatar delirious-lettuce avatar dvzubarev avatar gmacon avatar hkernbach avatar imetallica avatar joerg84 avatar joowani avatar jsteemann avatar maxkernbach avatar mirrorrim avatar mooncake4132 avatar patricklx avatar sumitsharansatsangi avatar tjoubert avatar valentingregoire avatar wshayes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.