Running Tentris Using Python
Requirements
Python>=3.12rdflib>=7glibc>=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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tentris-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
| tentris-1.1.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.1.0-py3-none-any.whl
| Download URL | tentris-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13b5e562d852325b3a0039e61aeeea481a7b5a9c7dca723ac72b4f7ff6889184
|
|
BLAKE2b-256 checksum How to use checksums |
2e3c1091a27cd3bb52fde362dc34f1ac43fe5b1a35c795f6ad2c51b570146102
|
| 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.1.0-cp312-abi3-manylinux_2_34_x86_64.whl
| Download URL | tentris-1.1.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 |
af93a1f02955f67729fad19ae95dae382ec37e2a068262fc427fab7fd56f556c
|
|
BLAKE2b-256 checksum How to use checksums |
24109cd48464efa618298527fb8b7d9b72703a58ecad5ca3e378e63003f32865
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|