Metadata-Version: 2.4
Name: GQLAlchemy
Version: 1.9.0
Summary: GQLAlchemy is a library developed to assist with writing and running queries in Memgraph.
Project-URL: Repository, https://github.com/memgraph/gqlalchemy
Author-email: Katarina Supe <katarina.supe@memgraph.io>, Andi Skrgat <andi.skrgat@memgraph.io>, Josip Mrden <josip.mrden@memgraph.io>
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: adlfs<2025.0.0,>=2023.9.0
Requires-Dist: dacite<2.0.0,>=1.6.0
Requires-Dist: neo4j<6.0.0,>=4.4.3
Requires-Dist: networkx<4.0.0,>=2.5.1
Requires-Dist: numpy<2.0,>=1.26.4; python_version >= '3.10' and python_version < '3.13'
Requires-Dist: numpy<3.0,>=2.2.6; python_version >= '3.13' and python_version < '4.0'
Requires-Dist: pandas<4.0,>=2.3; python_version >= '3.14' and python_version < '4.0'
Requires-Dist: pandas<=2.2.3; python_version >= '3.10' and python_version < '3.14'
Requires-Dist: psutil<7.0,>=5.9
Requires-Dist: pydantic<3.0.0,>=2.3.0
Requires-Dist: pymgclient<2.0.0,>=1.5.1
Requires-Dist: tensorflow==2.16.2; (python_version >= '3.10' and python_version < '3.12' and sys_platform != 'win32') or (python_version >= '3.12' and python_version < '3.13')
Provides-Extra: all
Requires-Dist: docker<7.0.0,>=6.1.3; extra == 'all'
Requires-Dist: pyarrow<17,>=16; (python_version >= '3.10' and python_version < '3.13') and extra == 'all'
Requires-Dist: pyarrow<24,>=22; (python_version >= '3.13' and python_version < '4.0') and extra == 'all'
Requires-Dist: pydot<5.0.0,>=1.4.2; extra == 'all'
Requires-Dist: tensorflow-gnn<2.0.0,>=1.0.0; ((python_version >= '3.10' and python_version < '3.12' and sys_platform != 'win32') or (python_version >= '3.12' and python_version < '3.13')) and extra == 'all'
Requires-Dist: torch<3.0,>=2.4; extra == 'all'
Provides-Extra: arrow
Requires-Dist: pyarrow<17,>=16; (python_version >= '3.10' and python_version < '3.13') and extra == 'arrow'
Requires-Dist: pyarrow<24,>=22; (python_version >= '3.13' and python_version < '4.0') and extra == 'arrow'
Provides-Extra: dgl
Requires-Dist: torch<3.0,>=2.4; extra == 'dgl'
Provides-Extra: docker
Requires-Dist: docker<7.0.0,>=6.1.3; extra == 'docker'
Provides-Extra: dot
Requires-Dist: pydot<5.0.0,>=1.4.2; extra == 'dot'
Provides-Extra: tfgnn
Requires-Dist: tensorflow-gnn<2.0.0,>=1.0.0; ((python_version >= '3.10' and python_version < '3.12' and sys_platform != 'win32') or (python_version >= '3.12' and python_version < '3.13')) and extra == 'tfgnn'
Requires-Dist: tensorflow==2.16.2; ((python_version >= '3.10' and python_version < '3.12' and sys_platform != 'win32') or (python_version >= '3.12' and python_version < '3.13')) and extra == 'tfgnn'
Requires-Dist: tf-keras<3.0,>=2.16; ((python_version >= '3.10' and python_version < '3.12' and sys_platform != 'win32') or (python_version >= '3.12' and python_version < '3.13')) and extra == 'tfgnn'
Provides-Extra: torch-pyg
Requires-Dist: torch<3.0,>=2.4; extra == 'torch-pyg'
Description-Content-Type: text/markdown

# GQLAlchemy

<p>
    <a href="https://github.com/memgraph/gqlalchemy/actions"><img src="https://github.com/memgraph/gqlalchemy/workflows/Build%20and%20Test/badge.svg" /></a>
    <a href="https://github.com/memgraph/gqlalchemy/blob/main/LICENSE"><img src="https://img.shields.io/github/license/memgraph/gqlalchemy" /></a>
    <a href="https://pypi.org/project/gqlalchemy"><img src="https://img.shields.io/pypi/v/gqlalchemy" /></a>
    <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
    <a href="https://memgraph.com/docs/gqlalchemy" alt="Documentation"><img src="https://img.shields.io/badge/documentation-GQLAlchemy-orange" /></a>
    <a href="https://github.com/memgraph/gqlalchemy/stargazers" alt="Stargazers"><img src="https://img.shields.io/github/stars/memgraph/gqlalchemy?style=social" /></a>
</p>

**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

- **Python 3.10+**
- [`pymgclient`](https://github.com/memgraph/pymgclient):

  - Install `pymgclient` [build prerequisites](https://memgraph.github.io/pymgclient/introduction.html#build-prerequisites)
  - Install `pymgclient` via pip:

  ```bash
  pip install --user pymgclient
  ```

> [!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](#prerequisites), run the following command to install
GQLAlchemy:

```bash
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:

```bash
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:

```bash
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:

```bash
pip install 'gqlalchemy[arrow]'
```

If you are using [Conda](https://docs.conda.io/en/latest/) for Python environment management, you can install GQLAlchemy through pip.

## Build & Test

The project uses [uv](https://docs.astral.sh/uv/) to manage dependencies and build the library. Clone or download the [GQLAlchemy source code](https://github.com/memgraph/gqlalchemy) locally and run the following command to build it from source with uv:

```bash
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:

```bash
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:

```bash
# 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](https://memgraph.com/docs/getting-started), and execute one of the following commands:

```bash
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:

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

## Development (how to build)

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

## Documentation

The GQLAlchemy documentation is available on [GitHub](https://memgraph.github.io/gqlalchemy/).

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.](https://memgraph.com)

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.
