GQLAlchemy is library developed with purpose of assisting writing and running queries on Memgraph.
Project description
GQLAlchemy
GQLAlchemy is library developed with purpose of assisting writing and running queries on Memgraph. GQLAlchemy supports high-level connection to Memgraph as well as modular query builder.
GQLAlchemy is built on top of Memgraph's low-level client pymgclient (pypi / documentation / GitHub).
Installation
To install gqlalchemy
, simply run the following command:
pip install gqlalchemy
Match Example
When working with the pymgclient
, Python developer can connect to database
and execute MATCH
cypher query with following syntax:
import mgclient
conn = mgclient.connect(host='127.0.0.1', port=7687)
cursor = conn.cursor()
cursor.execute("""
MATCH (from:Node)-[:Connection]->(to:Node)
RETURN from, to;
""")
result = cursor.fetchone()
conn.commit()
for result in results:
print(result['from'])
print(result['to'])
As we can see, example above can be error-prone, because we do not have
abstractions for creating a database connection and MATCH
query.
Now, rewrite the exact same query by using the functionality of gqlalchemy
.
from gqlalchemy import Memgraph
from gqlalchemy.build import Match
memgraph = Memgraph()
results = Match().node("Node",variable="from")
.to("Connection")
.node("Node",variable="to")
.execute()
for result in results:
print(result['from'])
print(result['to'])
License
Copyright (c) 2016-2021 Memgraph Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for GQLAlchemy-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44ba95232a291de896c3cfb21e1f81d215091d459e922faf2d7cf94bfdd796d6 |
|
MD5 | a64c030f6cc46994f8e161cb150fc50f |
|
BLAKE2b-256 | dfbc07d419c3a533e6927e9325fe083fcf5b035595c319eace778b63b7e00cec |