Metadata-Version: 2.4
Name: graph-db-interface
Version: 2.0.0
Summary: A simple interface to interact with a GraphDB instance
License-File: LICENSE
Author: Jan-Felix Klein
Author-email: janfelixklein@ooglemail.com
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: pydantic (>=2.11.7,<3.0.0)
Requires-Dist: python-snappy (>=0.7.3,<0.8.0)
Requires-Dist: rdflib (==7.1.3)
Requires-Dist: regex (>=2024.11.6,<2025.0.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Description-Content-Type: text/markdown

# graph_db_interface

[![PyPI version](https://badge.fury.io/py/graph-db-interface.svg)](https://badge.fury.io/py/graph-db-interface)
![Python](https://img.shields.io/badge/python-%3E=3.11-blue)
![License](https://img.shields.io/github/license/JaFeKl/graph_db_interface)


This repository acts as an interface to abstract SPARQL queries to callable methods to interact with a running GraphDB instance in an easier way.

# Installation


To install the current PyPI release, simply run the following command using your preferred python interpreter: 

```bash
pip install graph-db-interface
```

Or after cloning this repository you can also use poetry to install the package:
```bash
poetry install
```


# Getting Started
The package uses a single class named `GraphDB`. To use the interface, simply generate an object from this class:

```python
from graph_db_interface import GraphDB, GraphDBCredentials

credentials = GraphDBCredentials(
    base_url="<your_graph_db_url>",
    username="<your_graph_db_user>",
    password="<your_graph_db_password>",
    repository="<your_selected_repository_id>",
)

my_db = GraphDB(credentials=credentials)
```

# Running Tests
The test suite expects a running GraphDB instance and uses a dedicated test repository.

Required environment variables for tests:

- `GRAPHDB_URL`
- `GRAPHDB_USERNAME`
- `GRAPHDB_PASSWORD`
- `GRAPHDB_TEST_REPOSITORY`

Example:

```bash
export GRAPHDB_URL="http://localhost:7200"
export GRAPHDB_USERNAME="admin"
export GRAPHDB_PASSWORD="root"
export GRAPHDB_TEST_REPOSITORY="test-repo"
poetry run pytest tests -v
```

Note: application/runtime credentials loaded via `GraphDBCredentials.from_env()` still use `GRAPHDB_REPOSITORY` by default.

# License

The package is licensed under the [MIT license](LICENSE).


# Acknowledgements
This package is developed as part of the INF subproject of the [CRC 1574: Circular Factory for the Perpetual Product](https://www.sfb1574.kit.edu/english/index.php). This work is therefore supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) [grant-number: SFB-1574-471687386]

