# How to Become a GQLAlchemist?

### Introduction

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**](https://pypi.org/project/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**](https://memgraph.com/) as our main ingredient for storing and manipulating anything graph-like.

If you need help starting Memgraph, check out the [installation](https://docs.memgraph.com/memgraph/getting-started/installation) guide. Once we have Memgraph running, let's mix together Python and GQLAlchemy:

```python
from gqlalchemy import Memgraph

memgraph = Memgraph("127.0.0.1", 7687)
memgraph.execute_query(
    "CREATE (:Ingredient {name: 'Python'}), (:Ingredient {name: 'GQLAlchemy'}), (:Product {name: 'Memgraph'})"
)

memgraph.execute_query(
    """
    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`:

```python
from gqlalchemy import Match

ingredients = (
    Match()
    .node("Ingredient", variable="ingredient")
    .to()
    .node("Product", name="Memgraph")
    .execute()
)

for ingredient in ingredients:
    print(ingredient["ingredient"].properties["name"])
```

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.

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](https://github.com/memgraph/gqlalchemy) and feel free to contribute.

## Conclusion

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!

[![Read more about GQLAlchemy on memgraph.com](https://public-assets.memgraph.com/external/memgraph-read-more-gradient-1200.png align="left")](https://memgraph.com/blog?topics=GQLAlchemy&utm_source=hashnode&utm_medium=referral&utm_campaign=blog_repost&utm_content=banner#list)
