Retrieve graph data with Python instead of writing Cypher queries

GQLAlchemy is a standalone Object Grap Mapper (OGM) for Python that allows you to write object-oriented code to communicate with graph databases.

Install GQLAlchemy with Pip

pip install gqlalchemy
Copy

Full power and flexibility of Cypher

Query a graph database by writing objects in Python which GQLAlchemy automatically translates into Cypher queries.

Python:
from gqlalchemy import create
query = create()
     .node(labels="Person", name="Leslie")
     .to(relationship_type="FRIENDS_WITH")    
     .node(labels="Person", name="Ron")    
     .execute()
Copy
Cypher:
CREATE (:Person {name: 'Leslie'})-[:FRIENDS_WITH]->(:Person {name: 'Ron'});
Copy
from gqlalchemy import Memgraph, Node, Field
from typing import Optional

db = Memgraph()

class Person(Node):    
    id: str = Field(index=True, exist=True, unique=True, db=db)    
    username: Optional[str] = Field(index=True, exist=True, unique=True, db=db)    
    createdAt: Optional[str] = Field()
Copy

Efficient & high performing DB access

Cypher works well for small projects, but the boilerplate CRUD operations can get tedious on large scales without the right OGM.

Fully open-source Python library

GQLAlchemy is free to use, distribute, and modify. Contribute and make linking between graph database objects and Python objects better for everyone.

Memgraph Jupiter Notebooks available image

Jupyter Notebooks available

Learn to use GQLAlchemy and Memgraph quickly with the help of our Jupyter Notebooks. Any Jupyter Notebook can be exported in markdown format easily.

Arrow icon
Applications, not Analytics

Standalone OGM for Python that works best with Memgraph

GQLAlchemy was created as part of Memgraph — an open source platform for graph computation on streaming data that includes a suite of ecosystem tools like Lab for graph visualisation and MAGE, a library of graph algorithms, and more.

Memgraph Home Illustration
Build & Grow browser

GQLAlchemy Features

OGM Serialization and deserialization

Define nodes and relationships from your data model as Python classes. GQLAlchemy will automatically serialize and deserialize the needed objects.

Automatic schema validation

While graph databases are by design schemaless, GQLAlchemy provides you with the tools of defining and enforcing a strict schema of the graph data model.

On-disk storage

GQLAlchemy offers the option of storing some properties on disk instead of in memory.

Custom data loaders

GQLAlchemy offers the option of implementing custom data loaders from different sources and various formats such as Parquet, CSV, ORC, etc.

Query builder

Use standard Python syntax to traverse graphs by constructing queries with the GQLAlchemy query builder.

Manage Memgraph instances

You can start, stop, connect to and monitor Memgraph instances with GQLAlchemy.

Manage streams

You can create and start Kafka or Pulsar streams using GQLAlchemy to ingest data from various real-time sources.

Manage database triggers

GQLAlchemy implements a simple interface for maintaining database triggers on CREATE, UPDATE and DELETE operations.

Tutorial

Build a robust application using GQLAlchemy and Memgraph

This is a tutorial where you can learn how to build a small part of the Twitch analytics app with the help of GQLAlchemy. Our OGM and graph database make building graph-based apps much easier.

Arrow icon
Memgraph GQLAlchemy Build a robust aplication image
Applications, not Analytics

Start querying graph data with Python

Write object-oriented code to communicate with graph databases.

Build & Grow browser