Memgraph logo
Back to blog
How to Become a GQLAlchemist?

How to Become a GQLAlchemist?

June 2, 2021


Greetings, future GQLAlchemists! You are probably wondering what a GQLAlchemist is? Well lucky for you, you have come to the right place to find out. GQLAlchemists are powerful and wise users of the GQLAlchemy library in Python, and let me tell you how you can join the ranks of those elite users. As you initiation step, all you have to do is run: pip install gqlalchemy and you are already halfway there.

Start mixing ingredients

I hope that your initiation process went painlessly, now we can do a few experiments to test out just how powerful we truly are when using this library. But before we begin meddling with the forbidden open source knowledge, let us remember the fundamentals of alchemy, the Equivalent Exchange, you cannot create the best product without using the best ingredients, and that's why we will use Memgraph as our main ingredient for storing and manipulating anything graph-like.

If you need help starting Memgraph, check out the installation guide. Once we have Memgraph running, let's mix together Python and GQLAlchemy:

from gqlalchemy import Memgraph
memgraph = Memgraph("", 7687)
    "CREATE (:Ingredient {name: 'Python'}), (:Ingredient {name: 'GQLAlchemy'}), (:Product {name: 'Memgraph'})"
    MATCH (n {name: 'Python'}), (m {name: 'GQLAlchemy'}), (p {name: 'Memgraph'})
    MERGE (n)-[:TO {version: 3.9}]->(p)
    MERGE (m)-[:TO {version: 1.02}]->(p)

Amazing job, GQLAlchemists! We have created three connected nodes inside Memgraph. We have two Ingredient nodes Python and GQLAlchemy, and one Product node Memgraph.

Let's try querying it now using one of the tools from GQLAlchemy, a small query builder Match:

from gqlalchemy import Match
ingredients = (
    .node("Ingredient", variable="ingredient")
    .node("Product", name="Memgraph")
for ingredient in ingredients:

Wow, GQLAlchemists! You have successfully used the query builder to easily construct a Cypher query and execute it on Memgraph. What we have done is simply fetched all elements that have a variable set, and are connected to the Memgraph node. You can easily and more intuitively construct simple queries, but for more complex ones use execute_and_fetch from Memgraph.

Since you have mastered the fundamentals of GQLAlchemy, head on to use it on your projects, play around with it, and feel free to tell us about the amazing projects that you will build with GQLAlchemy.

What are the future plans?

Currently, we are working on NetworkX support in GQLAlchemy, and are planning to extend the query builder to make it more robust. For now, we only support the openCypher standard, but the general idea is to extend support for all Graph Query Languages. If you think there is something crucial that is missing or are even willing the try out your expertise in Python and graphs, check out our GitHub repository and feel free to contribute.


GQLAlchemy is meant for all developers who will use Memgraph or any other products that support GQL. And just remember, a good GQLAlchemist doesn't mix nodes and edges!

Join us on Discord!
Find other developers performing graph analytics in real time with Memgraph.
© 2024 Memgraph Ltd. All rights reserved.