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.

Metadata

Release files for tentris 1.0.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.0.0
File Interpreter ABI Platform
tentris-1.0.0-py3-none-any.whl Python 3 none any Details
tentris-1.0.0-cp312-abi3-manylinux_2_34_x86_64.whl CPython 3.12 abi3 Linux glibc 2.34+ x86-64 Details

Total release size: 11.8 MB

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

Download URL tentris-1.0.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e05bde67e62bdb205eef55769b7b4118a7cc1d6f1b582820ad0b616b35fb900
BLAKE2b-256 checksum
How to use checksums
0b6bdb417fd5f627dd5ea6645359ae939fc28b124deb3aa516017d6e71932daa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

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

Download URL tentris-1.0.0-cp312-abi3-manylinux_2_34_x86_64.whl
Size 11.8 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
51ef710015293839c138999fa33c5ee783990e7134031de0eef67ef8c67a4ef1
BLAKE2b-256 checksum
How to use checksums
6a04610716b9134784f7b66f1d842e6febff522ec4ae80f0bc321d1e0f98c4d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3
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