pymgclient - Memgraph database adapter for Python language
pymgclient is a Memgraph database adapter for Python
programming language compliant with the DB-API 2.0 specification described by
PEP 249.
mgclient module is the current implementation of the adapter. It is implemented
in C as a wrapper around mgclient, the
official Memgraph client library. As a C extension, it is only compatible with
the CPython implementation of the Python programming language.
pymgclient only works with Python 3.
Check out the documentation if you need help with
installation
or if you want to
build
pymgclient for yourself!
Documentation
Online documentation can be found on GitHub
pages.
You can also build a local version of the documentation by running make
from
the docs
directory. You will need Sphinx
installed in order to do that.
Code sample
Here is an example of an interactive session showing some of the basic
commands:
>>> import mgclient
>>> conn = mgclient.connect(host='127.0.0.1', port=7687)
>>> cursor = conn.cursor()
>>> cursor.execute("""
CREATE (n:Person {name: 'John'})-[e:KNOWS]->
(m:Person {name: 'Steve'})
RETURN n, e, m
""")
>>> row = cursor.fetchone()
>>> print(row[0])
(:Person {'name': 'John'})
>>> print(row[1])
[:KNOWS]
>>> print(row[2])
(:Person {'name': 'Steve'})
>>> conn.commit()