memgraph / gqlalchemy

GQLAlchemy is a library developed with the purpose of assisting in writing and running queries on Memgraph. GQLAlchemy supports high-level connection to Memgraph as well as modular query builder.

Home Page:https://pypi.org/project/gqlalchemy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docs needed for connecting to Memgraph from gqlalchemy

thedraketaylor opened this issue · comments

In docs/index.md, there is a line that states "Check the Python quick start guide to learn how to connect to Memgraph using GQLAlchemy."

However, the linked page states: "Both Neo4j Python client and GQLAlchemy can be used to connect to Memgraph with Python. This guide will show how to use Neo4j Python client and for more information on GQLAlchemy, check out its documentation."

There needs to be docs to explain how to connect to Memgraph using gqlalchemy.

Hi @thedraketaylor, thank you for reporting this. We moved the whole GQLAlchemy docs from Memgraph documentation and then we didn't catch that link. Thank you for pointing it out, I'll add it. Here is the code snippet for now:

from gqlalchemy import Memgraph

# Make a connection to the database
memgraph = Memgraph(host='127.0.0.1', port=7687)

# Delete all nodes and relationships
query = "MATCH (n) DETACH DELETE n"

# Execute the query
memgraph.execute(query)

# Create a node with the label FirstNode and message property with the value "Hello, World!"
query = """CREATE (n:FirstNode)
           SET n.message = '{message}'
           RETURN 'Node '  + id(n) + ': ' + n.message AS result""".format(message="Hello, World!")

# Execute the query
results = memgraph.execute_and_fetch(query)

# Print the first member
print(list(results)[0]['result'])

Also, refer to the tests for more examples.