Skip to main content

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

pip install tentris

or edit your requirements.txt as follows.

# ... your other dependencies
tentris

Getting Started

The Tentris Python library is a plugin for rdflib.

Native (Linux only)

With the native TentrisStore, Tentris is embedded in Python applications.

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

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.

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()}")

For more information about setting up a disk-based instance of Tentris, please refer to the chapter Binary.

Remote Login

To log into a remote instance of Tentris that has authentication enabled, the following can be used.

from tentris import TentrisHTTPStore
import rdflib
import requests

def login(url: str, user: str, password: str) -> str:
    s = requests.Session()
    s.post(f"{url}/login", {"username": user, "password": password})

    c = s.cookies.get("tentris")
    return f"tentris={c}"


SERVER = "https://remote-server-with-auth.example.com"

cookie = login(SERVER, "my-username", "my-password")
graph = rdflib.Graph(store=TentrisHTTPStore(SERVER, headers={"Cookie": cookie}))

for binding in graph.query("SELECT * WHERE { ?s ?p ?o } LIMIT 10"):
    print(f"{binding.s.n3()} {binding.p.n3()} {binding.o.n3()}")

Metadata

Release files for tentris 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for tentris 1.4.0
File Interpreter ABI Platform
tentris-1.4.0-py3-none-any.whl Python 3 none any Details
tentris-1.4.0-cp312-abi3-manylinux_2_34_x86_64.whl CPython 3.12 abi3 Linux glibc 2.34+ x86-64 Details

Total release size: 11.6 MB

Release files / tentris-1.4.0-py3-none-any.whl

Download URL tentris-1.4.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c45bbde7996a2d5757c6e5bd0b6e2ba12e1f6e99d19e613e57139eebec25cc4
BLAKE2b-256 checksum
How to use checksums
179a50545824c24435f6aa5d16ee3d552717473cb2d34eb9cc1d31be5b4f70c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / tentris-1.4.0-cp312-abi3-manylinux_2_34_x86_64.whl

Download URL tentris-1.4.0-cp312-abi3-manylinux_2_34_x86_64.whl
Size 11.6 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
9df75091d638b636ed3df0e7fd67b3a017f327dd6800cac0f8ab07040e68ad44
BLAKE2b-256 checksum
How to use checksums
ada838d94cc1946228d73050e37d9f011a9e74d7f90ae0c4ed2b4ddd0ab1b9f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page