Skip to main content

GQLAlchemy is a library developed to assist with writing and running queries in Memgraph.

Project description

GQLAlchemy

Code style: black

GQLAlchemy is a fully open-source Python library and Object Graph Mapper (OGM) - a link between graph database objects and Python objects.

An Object Graph Mapper or OGM provides a developer-friendly workflow that allows for writing object-oriented notation to communicate with graph databases. Instead of writing Cypher queries, you will be able to write object-oriented code, which the OGM will automatically translate into Cypher queries.

Installation

Prerequisites

[!NOTE] GQLAlchemy is tested on Python 3.10 through 3.14 in CI. Some optional extras (for example TensorFlow/TF-GNN stacks) are available only for a subset of Python versions due to upstream wheel availability.

Install GQLAlchemy

After you’ve installed the prerequisites, run the following command to install GQLAlchemy:

pip install gqlalchemy

With the above command, you get the default GQLAlchemy installation which doesn’t include import/export support for certain formats (see below). To get additional import/export capabilities, use one of the following install options:

pip install gqlalchemy[arrow] # Support for the CSV, Parquet, ORC and IPC/Feather/Arrow formats
pip install gqlalchemy[dgl] # DGL support (also includes torch)
pip install gqlalchemy[docker] # Docker support

pip install gqlalchemy[all] # All of the above

If you intend to use GQLAlchemy with PyTorch Geometric support, that library must be installed manually:

pip install gqlalchemy[torch_pyg] # prerequisite
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.13.0+cpu.html"

If you are using the zsh terminal, surround gqlalchemy[$extras] with quotes:

pip install 'gqlalchemy[arrow]'

If you are using Conda for Python environment management, you can install GQLAlchemy through pip.

Build & Test

The project uses uv to manage dependencies and build the library. Clone or download the GQLAlchemy source code locally and run the following command to build it from source with uv:

uv sync --all-extras

The uv sync --all-extras command installs GQLAlchemy with all extras (optional dependencies). Alternatively, you can use the --extra option to define what extras to install:

uv sync # No extras

uv sync --extra arrow # Support for the CSV, Parquet, ORC and IPC/Feather/Arrow formats
uv sync --extra dgl # Installs torch (DGL must be installed separately, see below)
uv sync --extra docker # Docker support
uv sync --extra tfgnn # TFGNN support

The dgl and torch_pyg extras install PyTorch only. DGL and PyTorch Geometric wheels must be installed separately due to their custom package indexes:

# DGL
uv sync --extra dgl
uv pip install dgl -f https://data.dgl.ai/wheels/torch-2.4/repo.html

# PyTorch Geometric
uv sync --extra torch_pyg
uv pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-2.4.0+cpu.html

To run the tests, make sure you have an active Memgraph instance, and execute one of the following commands:

uv run pytest . -k "not slow" # If all extras installed

uv run pytest . -k "not slow and not extras" # Otherwise

If you’ve installed only certain extras, it’s also possible to run their associated tests:

uv run pytest . -k "arrow"
uv run pytest . -k "dgl"
uv run pytest . -k "docker"
uv run pytest . -k "tfgnn"

Development (how to build)

uv run flake8 .
uv run black .
uv run pytest . -k "not slow and not extras"

Documentation

The GQLAlchemy documentation is available on GitHub.

The reference guide can be generated from the code by executing:

pip3 install pydoc-markdown
pydoc-markdown

Other parts of the documentation are written and located at docs directory. To test the documentation locally execute:

pip3 install mkdocs
pip3 install mkdocs-material
pip3 install pymdown-extensions
mkdocs serve

License

Copyright (c) 2016-2023 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gqlalchemy-1.10.0.tar.gz (993.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gqlalchemy-1.10.0-py3-none-any.whl (105.8 kB view details)

Uploaded Python 3

File details

Details for the file gqlalchemy-1.10.0.tar.gz.

File metadata

  • Download URL: gqlalchemy-1.10.0.tar.gz
  • Upload date:
  • Size: 993.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gqlalchemy-1.10.0.tar.gz
Algorithm Hash digest
SHA256 08a60cf452b828d8a5cf8ddd5a9325868aa608cb30b5be85245bb9a8b1c48407
MD5 cf38b3e56f55a0c536418c36cec8afbb
BLAKE2b-256 8c5331c3edb6b1cc85128e9ca3d69e237ea03c3143684613fdc34aaa5d580fb0

See more details on using hashes here.

File details

Details for the file gqlalchemy-1.10.0-py3-none-any.whl.

File metadata

  • Download URL: gqlalchemy-1.10.0-py3-none-any.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gqlalchemy-1.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adc8098f50d6dd217003c4f5967fa3b018fec3c3fce94ac7999458caf7a41c4f
MD5 4106d2f6d63b29a6b56c1502ba8a340d
BLAKE2b-256 97c7d002c624b1bfffecc635c0000e5f89b64b294393d2bb3ea539992cf68f13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page