/rd-cloudfit-python-aiocypher

Async Python wrapper for Cypher Query Language drivers

Primary LanguagePythonApache License 2.0Apache-2.0

aiocypher

A partial Python asyncio wrapper for various Cypher Query Language drivers

This is not intended to be a full async driver, but a wrapper implementation using run_in_executor to allow asynchronous usage of the underlying synchronous driver, replicating the interface of the wrapped library where possible.

Installation & Usage

pip3 install aiocypher

Note the neo4j driver is installed by default, if you want to use AgensGraph, try pip3 install aiocypher[agensgraph].

Usage Example

import asyncio
from aiocypher.aioneo4j.driver import Driver
from aiocypher import Config

config = Config(
    address='bolt://localhost:17687',
    username='neo4j',
    password='test'
)
driver = Driver(config)


async def basic_query(driver: Driver):
    async with driver as driver:
        async with driver.session(database='neo4j') as session:
            async with session.begin_transaction() as tx:
                await tx.run("CREATE(n:TestNode{name:'example'})")

            async with session.begin_transaction() as tx:
                result = await tx.run("MATCH(n:TestNode) RETURN n.name")
                record = result.single()
                print(record)

asyncio.run(basic_query(driver))

Developing with this project

A Makefile is provided at the top-level of the repository to run common tasks. Run make in the top directory of this repository to see what actions are available.

Documentation

The API is well documented in the docstrings of the module aiocypher. A rendered version of this documentation is available here.

Questions?

Any questions, please contact one of the R&D Cloud-Fit Production team on cloudfit-opensource@rd.bbc.co.uk, or file an Issue on the repo.