# Running Tentris Using Python
## Requirements
* `Python>=3.12`
* `rdflib>=7`
* `glibc>=2.34` (e.g. ubuntu-22.04 or later)
> **Note:** Connecting to local/remote Tentris instances via HTTP is supported on all plattforms.
> Running Tentris **within** python is only supported on Linux.
## Install
```shell
pip install tentris
```
or edit your `requirements.txt` as follows.
```txt
# ... your other dependencies
tentris
```
## Getting Started
The Tentris Python library is a plugin for [rdflib](https://rdflib.readthedocs.io/en/7.1.0/gettingstarted.html).
### Native (Linux only)
With the native `TentrisStore`, Tentris is embedded in Python applications.
```python
import tentris
import rdflib
# Create an RDFLib graph using Tentris as its backend
graph = rdflib.Graph(store="Tentris")
# Load the graph using the SPARQL Update operation `LOAD`
# https://www.w3.org/TR/2013/REC-sparql11-update-20130321/#load
graph.update("LOAD <https://files.tentris.io/mona-lisa.ttl>")
# Query the Mona Lisa knowledge graph
query_str = """
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?name WHERE {
dbr:Mona_Lisa dbo:author ?person .
?person foaf:name ?name .
}
"""
for binding in graph.query(query_str):
print(f"{binding.name.n3()}")
```
The `TentrisStore` operates in-memory and does not persist data in the disk.
To use a disk-based instance of Tentris, the [HTTP-based store](#http) should be used.
### HTTP (Any Operating System)
Remote or local instances of Tentris can be queries using the HTTP-based `TentrisHTTPStore`.
#### Local
Assuming a Tentris server is running on the localhost listening to the default port, it can be queried as shown in the
example below.
```python
import tentris
import rdflib
graph = rdflib.Graph(store="TentrisHTTP")
for binding in graph.query("SELECT * WHERE { ?s ?p ?o } LIMIT 10"):
print(f"{binding.s.n3()} {binding.p.n3()} {binding.o.n3()}")
```
#### Remote
To query remote instances of Tentris, the URL needs to be explicitly stated.
```python
from tentris import TentrisHTTPStore
import rdflib
graph = rdflib.Graph(store=TentrisHTTPStore("https://dbpedia.data.dice-research.org"))
for binding in graph.query("SELECT * WHERE { ?s ?p ?o } LIMIT 10"):
print(f"{binding.s.n3()} {binding.p.n3()} {binding.o.n3()}")
```
Raw data
{
"_id": null,
"home_page": null,
"name": "tentris",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Tentris GmbH <info@tentris.io>",
"keywords": "tentris, knowledge graph, RDF, SPARQL, graph database, rdflib, semantic web",
"author": null,
"author_email": "Tentris GmbH <info@tentris.io>",
"download_url": null,
"platform": null,
"description": "# Running Tentris Using Python\n\n## Requirements\n\n* `Python>=3.12`\n* `rdflib>=7`\n* `glibc>=2.34` (e.g. ubuntu-22.04 or later)\n\n> **Note:** Connecting to local/remote Tentris instances via HTTP is supported on all plattforms.\n> Running Tentris **within** python is only supported on Linux.\n\n## Install\n\n```shell\npip install tentris\n```\n\nor edit your `requirements.txt` as follows.\n\n```txt\n# ... your other dependencies\ntentris\n```\n\n## Getting Started\n\nThe Tentris Python library is a plugin for [rdflib](https://rdflib.readthedocs.io/en/7.1.0/gettingstarted.html).\n\n### Native (Linux only)\n\nWith the native `TentrisStore`, Tentris is embedded in Python applications.\n\n```python\nimport tentris\nimport rdflib\n\n# Create an RDFLib graph using Tentris as its backend\ngraph = rdflib.Graph(store=\"Tentris\")\n\n# Load the graph using the SPARQL Update operation `LOAD`\n# https://www.w3.org/TR/2013/REC-sparql11-update-20130321/#load \ngraph.update(\"LOAD <https://files.tentris.io/mona-lisa.ttl>\")\n\n# Query the Mona Lisa knowledge graph\nquery_str = \"\"\"\n PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n PREFIX dbr: <http://dbpedia.org/resource/>\n PREFIX dbo: <http://dbpedia.org/ontology/>\n\n SELECT ?name WHERE {\n dbr:Mona_Lisa dbo:author ?person .\n ?person foaf:name ?name .\n }\n\"\"\"\n\nfor binding in graph.query(query_str):\n print(f\"{binding.name.n3()}\")\n```\n\nThe `TentrisStore` operates in-memory and does not persist data in the disk.\nTo use a disk-based instance of Tentris, the [HTTP-based store](#http) should be used.\n\n### HTTP (Any Operating System)\n\nRemote or local instances of Tentris can be queries using the HTTP-based `TentrisHTTPStore`.\n\n#### Local\n\nAssuming a Tentris server is running on the localhost listening to the default port, it can be queried as shown in the\nexample below.\n\n```python\nimport tentris\nimport rdflib\n\ngraph = rdflib.Graph(store=\"TentrisHTTP\")\n\nfor binding in graph.query(\"SELECT * WHERE { ?s ?p ?o } LIMIT 10\"):\n print(f\"{binding.s.n3()} {binding.p.n3()} {binding.o.n3()}\")\n```\n\n#### Remote\n\nTo query remote instances of Tentris, the URL needs to be explicitly stated.\n\n```python\nfrom tentris import TentrisHTTPStore\nimport rdflib\n\ngraph = rdflib.Graph(store=TentrisHTTPStore(\"https://dbpedia.data.dice-research.org\"))\n\nfor binding in graph.query(\"SELECT * WHERE { ?s ?p ?o } LIMIT 10\"):\n print(f\"{binding.s.n3()} {binding.p.n3()} {binding.o.n3()}\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Python bindings for using the RDF graph database Tentris RDF rdflib",
"version": "0.19.10b0",
"project_urls": {
"Changelog": "https://github.com/tentris/tentris/releases",
"Documentation": "https://docs.tentris.io/running_with_python.html",
"Homepage": "https://tentris.io",
"Issues": "https://github.com/tentris/tentris/issues",
"License": "https://tentris.io/#eula",
"Repository": "https://github.com/tentris/tentris"
},
"split_keywords": [
"tentris",
" knowledge graph",
" rdf",
" sparql",
" graph database",
" rdflib",
" semantic web"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f9ed5af64b5677e8f5b0723d5a67f8336031de6f0e5ab544db5308db9a1b894d",
"md5": "db4c029b39bb56c86b0282018927d53f",
"sha256": "f34f8c8b661bb6d91dcb674d1fe91487f9821fae3f39630e45709415c39e6174"
},
"downloads": -1,
"filename": "tentris-0.19.10b0-cp312-abi3-manylinux_2_34_x86_64.whl",
"has_sig": false,
"md5_digest": "db4c029b39bb56c86b0282018927d53f",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.12",
"size": 10434101,
"upload_time": "2025-10-10T11:44:41",
"upload_time_iso_8601": "2025-10-10T11:44:41.684699Z",
"url": "https://files.pythonhosted.org/packages/f9/ed/5af64b5677e8f5b0723d5a67f8336031de6f0e5ab544db5308db9a1b894d/tentris-0.19.10b0-cp312-abi3-manylinux_2_34_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4372190c8bb16ac4a70a42698f227feff6db9eceabd97388454a2a452c36afaa",
"md5": "ac5fd5dc3f7bbbce8aaf5ba7ff301383",
"sha256": "1e7803c4b17e74df6249cf52e61441ffb87a0b59288e290e9563debaf87381d8"
},
"downloads": -1,
"filename": "tentris-0.19.10b0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac5fd5dc3f7bbbce8aaf5ba7ff301383",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 10888,
"upload_time": "2025-10-10T11:44:43",
"upload_time_iso_8601": "2025-10-10T11:44:43.704342Z",
"url": "https://files.pythonhosted.org/packages/43/72/190c8bb16ac4a70a42698f227feff6db9eceabd97388454a2a452c36afaa/tentris-0.19.10b0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-10 11:44:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tentris",
"github_project": "tentris",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tentris"
}