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.2.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.2.0
File Interpreter ABI Platform
tentris-1.2.0-py3-none-any.whl Python 3 none any Details
tentris-1.2.0-cp312-abi3-manylinux_2_34_x86_64.whl CPython 3.12 abi3 Linux glibc 2.34+ x86-64 Details

Total release size: 11.4 MB

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

Download URL tentris-1.2.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae0c56d05becca451cfe235f634313e72c64d77d42f626d13efad7beede34e36
BLAKE2b-256 checksum
How to use checksums
c260f371c07af909cb077dc2cd3872505a3bdc61ec07737eb644b706f7a3cfaf
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 Sep 17, 2026.

Transparency log

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

Download URL tentris-1.2.0-cp312-abi3-manylinux_2_34_x86_64.whl
Size 11.3 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
858e20da511f03a3eeb7c8da5d1b8c4acd0c6777fc85dedd7db97223863442ba
BLAKE2b-256 checksum
How to use checksums
eb6023bb74f73b8083035149234db0e27366ff6020d081784531ab93a79f3584
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 Sep 17, 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