Skip to main content

Fetch an AQL directly to a Python graph representation (In NetworkX, IGraph, or Graph-Tool)

Project description

arangodb-pythongraph

Run an AQL and get a Python network object in return

Installation

pip install arangodb-pythongraph

Duh.

Graph frameworks

This package is based on pyintergraph and thus supports extraction to NetworkX, python-IGraph and Graph-Tools graph objects. However, these libraries are not defined as requirements for this package and if you want to extract to each of them you are required to install the necessary package accordingly.

Usage

All queries must return path objects.

Simple extraction

from arangodb_pythongraph import execute_to_pygraph

db = ... # ArangoDB connection (use python-arango package)
example_query = '''
  FOR v0 in vertex_collection
    FOR e, v, p IN OUTBOUND v0 edge_collection
      RETURN p
'''
python_graph = execute_to_pygraph(db, query)
nx_graph = python_graph.to_networkx()
gt_graph = python_graph.to_graph_tool()
ig_graph = python_graph.to_igraph()

Exporting the graph

If you want to export the graph (for example to use it with Gephi), you might run into trouble if you have nested or complex attributes in your graph. To overcome this, use the cleanup argument:

python_graph = execute_to_pygraph(db, query, cleanup=True)

The functionality might be missing some use cases so if you encounter problems while exporting the graph to file, please open an Issue describing the error you're getting together with a portion of the data you're trying to export.

Attaching functionality to the AQL object

For a neater use, run arangodb_pythongraph.register()

Before:

python_graph = execute_to_pythongraph(db, query)

After:

python_graph = db.aql.execute_to_pythongraph(query)

Development

Contributions are more than welcome :)

Note that the project is managed with poetry, so make sure you use poetry to update the pypoject file.

Running tests

To run the tests you must have a running instance of ArangoDB. If you don't have a connection to an existing DB you can use docker to run it easily.

Once you have a running ArangoDB connection, create a DB named 'test' (or any other name you choose), and run tests with pytest

ARANGODB_PASS=<pass_goes_here> ARANGODB_NAME=test poetry run pytest

Project details


Download files

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

Source Distribution

arangodb-pythongraph-0.1.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

arangodb_pythongraph-0.1.4-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file arangodb-pythongraph-0.1.4.tar.gz.

File metadata

  • Download URL: arangodb-pythongraph-0.1.4.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.1 Darwin/18.7.0

File hashes

Hashes for arangodb-pythongraph-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ee69464b58c6358a1579186ef15d3c0db941b0182ad3414324e6860c4c0489fc
MD5 dce185cf7e4e5fd3df321b1501cabba8
BLAKE2b-256 a24b5d278c6366c4b7e3e7c7449578a44ceb20ad5c51db2a459469e7b3485d4a

See more details on using hashes here.

File details

Details for the file arangodb_pythongraph-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for arangodb_pythongraph-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f20d83243510474cd84f38b806b64294cd3820937c3082148d08d5159f8e4a1d
MD5 7bfbb244fe4c260f674b21d8cf55dc2d
BLAKE2b-256 43fbc886beec4e8b27b46932e21a804728c22ca8710e4b2eea2e2fa3d6c11a7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page