Skip to main content

oxilite

oxilite for Python

PyPI license

An Oxigraph-compatible SPARQL 1.1 store for Python, on SQLite. It has the API of pyoxigraph and keeps the whole dataset in one SQLite file. The same data can also be queried with openCypher and Datalog, reasoned over with RDFS / OWL, described by SHACL shapes, filled from JSON-LD documents and Verifiable Credentials, and read at any past version.

Website · Python reference · Tutorial · Source · Issues

pip install oxilite

Quick start

from oxilite import Store, NamedNode, Literal, Quad, RdfFormat

store = Store("data.sqlite")                     # Store() for an in-memory store
store.load("""
    @prefix ex: <http://example.com/> .
    ex:ada a ex:Person ; ex:name "Ada" ; ex:knows ex:alan .
""", RdfFormat.TURTLE)
store.add(Quad(NamedNode("http://example.com/alan"), NamedNode("http://example.com/name"), Literal("Alan")))

for solution in store.query("SELECT ?name WHERE { ?p <http://example.com/name> ?name }"):
    print(solution["name"].value)

store.update("DELETE WHERE { ?s <http://example.com/knows> ?o }")
print(len(store))

query returns what pyoxigraph returns: QuerySolutions for SELECT, QueryBoolean for ASK, and QueryTriples for CONSTRUCT and DESCRIBE. Each can be serialized to JSON, XML, CSV or TSV (RDF for triples).

Coming from pyoxigraph

import oxilite as pyoxigraph

Terms, formats, results, parse, serialize, parse_query_results and every Store method keep their names, arguments and results. pyoxigraph's own test suite runs against this package on every build. Two kinds of test fail, and they are allow-listed:

  • custom Python functions inside SPARQL: a query is one SQL statement, so SQLite cannot call Python for each row
  • LOAD of a remote URL: the core does no network I/O

Store(path) opens a SQLite file. Given an existing directory, as pyoxigraph's paths are, it uses oxilite.sqlite inside it.

Cypher and Datalog over the same data

opts = {"base": "http://example.com/"}
store.cypher("CREATE (:Person {name: 'Grace'})-[:KNOWS {since: 1950}]->(:Person {name: 'Ada'})", **opts)
r = store.cypher("MATCH (a:Person {name: $name})-[:KNOWS]->(b) RETURN b.name AS friend", {"name": "Grace"}, **opts)
print(r.records)                          # [{'friend': 'Ada'}]

program = """
@prefix ex: <http://example.com/> .
reach(?x, ?y) :- ex:KNOWS(?x, ?y).
reach(?x, ?z) :- ex:KNOWS(?x, ?y), reach(?y, ?z).
?- reach(?a, ?b).
"""
print(store.datalog(program).records)     # [{'a': <NamedNode …>, 'b': <NamedNode …>}]

Nodes are IRIs, labels are rdf:type, properties are literal triples, and relationships are triples, with an RDF 1.2 reifier when they carry properties. So SPARQL sees everything Cypher writes. A Datalog program whose recursion is linear runs as one recursive SQL statement.

Synalog, the Datalog-family language for AI agents, runs over the same data, reading triples as tables:

r = store.synalog("""
# @table knows <http://example.com/KNOWS>
@Recursive(Reach, 10);
Reach(a:, b:) distinct :- knows(subject: a, object: b);
Reach(a:, b:) distinct :- Reach(a:, b: m), knows(subject: m, object: b);
""", "Reach")
print(r.records)                          # [{'a': 'http://example.com/…', 'b': '…'}]

Reasoning, schemas, documents, history

from datetime import datetime, timezone
from oxilite import DefaultGraph, NamedNode, RdfFormat, Store

store = Store()
store.load("@prefix ex: <http://example.com/> . ex:rex a ex:Dog .", RdfFormat.TURTLE)
onto = NamedNode("http://example.com/onto")
store.load("@prefix ex: <http://example.com/> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
           "ex:Dog rdfs:subClassOf ex:Animal .", RdfFormat.TURTLE, to_graph=onto)
store.register_schema_graph(onto, "ontology", applies_to=[DefaultGraph()])   # the schema registry

assert store.query("ASK { ex:rex a ex:Animal }", reasoning="rdfs", prefixes={"ex": "http://example.com/"})
store.materialize(engine="reasonable")            # OWL 2 RL closure; query it with include_inferred=True

docs = store.jsonld()                             # JSON-LD stored byte for byte, RDF in a named graph
docs.put('{"@context": {"name": "http://schema.org/name"}, "@id": "urn:uuid:1", "name": "Ada"}')
vcs = store.credentials()                         # Verifiable Credentials 1.1 and 2.0, indexed by
vcs.find(issuer="did:example:academy", valid_at=datetime.now(timezone.utc))  # issuer, subject, validity

versioned = Store(versioning="log")               # an immutable change log
with versioned.commit(author="ada", message="import"):
    versioned.update('INSERT DATA { <urn:t1> <urn:status> "open" }')
with versioned.commit(author="grace", message="close"):
    versioned.update('DELETE DATA { <urn:t1> <urn:status> "open" } ; INSERT DATA { <urn:t1> <urn:status> "done" }')
print([s["s"].value for s in versioned.query("SELECT ?s { <urn:t1> <urn:status> ?s }", as_of="HEAD~1")])  # ['open']

Examples

Each example is a short script that runs top to bottom, prints what it does and asserts its output. CI runs all of them against every build.

Example Shows
01_quickstart.py A store in one file: load, add, SELECT / ASK / CONSTRUCT, results as CSV or dicts, dump, reopen
02_cypher_property_graph.py openCypher writes and reads, parameters, paths, aggregation, and SPARQL over the same data
03_datalog.py Recursive rules, negation, aggregation, and materialized inferences
04_reasoning_and_schemas.py RDFS at query time, OWL 2 RL materialization, registered ontologies and SHACL shapes
05_jsonld_and_credentials.py JSON-LD documents and Verifiable Credentials, found by issuer, subject and validity
06_time_travel.py Commits, queries at past versions, history, diffs, and purging
07_full_text_search.py FTS5 full-text search from SPARQL
08_threads_and_asyncio.py Thread pools, asyncio.to_thread, and read-only handles
python-tour/tour.py Everything above in one script: the code of the Python tutorial

API at a glance

Method Does
Store(path=None, *, library=None, text_index=False, versioning="off", …), Store.read_only(path) Open a file, a directory or memory; library loads a system libsqlite3
query(sparql, *, base_iri, prefixes, use_default_graph_as_union, default_graph, named_graphs, substitutions, reasoning, include_inferred, include_schema_graphs, as_of) SPARQL 1.1 / 1.2 query
update(sparql) SPARQL Update, atomically
load, bulk_load, dump Turtle, N-Triples, N-Quads, TriG, N3, RDF/XML, JSON-LD, from str, bytes, files or paths
add, extend, bulk_extend, remove, in, len, iteration, quads_for_pattern Quad-level access
named_graphs, add_graph, clear_graph, remove_graph, clear, optimize, backup Graphs and maintenance
synalog(program, predicate, …), synalog_sql Synalog over the store as tables; rows of plain values
explain, explain_update, explain_cypher, explain_datalog The SQL each language compiles to
cypher(query, params, **options) openCypher read or write: CypherResult(columns, rows, records, stats)
datalog, datalog_materialize Recursive rules, stratified negation, aggregation
materialize(engine), clear_inferences() OWL 2 RL materialization ("sql" or "reasonable")
register_schema_graph, schema_graphs, set_schema_graph_active, unregister_schema_graph, drop_schema_graph, shape_index, install_system_graphs The schema registry
jsonld(**options), credentials(**options) JSON-LD documents and Verifiable Credentials
versioning, set_versioning, commit, set_commit_info, history, changes, diff, purge History and time travel
parse, serialize, parse_query_results RDF and results I/O without a store

Every result is typed: the package ships py.typed and passes mypy --strict. Store calls release the GIL. The full reference is docs/python.md.

Platforms

Wheels use the stable ABI, so each one serves CPython 3.9 and every later version:

  • Linux: glibc x86_64 and aarch64, musl x86_64
  • macOS: x86_64 and arm64
  • Windows: x64

On other platforms, pip builds the package from the source distribution, which needs a Rust toolchain. To build it yourself, see building and publishing the package.

The oxilite family

oxilite is an Oxigraph-compatible RDF database and SPARQL 1.1 engine that stores its data in SQLite. It runs anywhere SQLite runs: in-process, on a system or vendor libsqlite3, and on Cloudflare D1 and in Durable Objects.

Package What it is for
oxilite (Rust) The store: a drop-in for oxigraph::store::Store, plus AsyncStore for D1
oxilite (Python) This package: the API of pyoxigraph
@oxilite/node Node.js bindings, with the API of Oxigraph's JS package
@oxilite/d1 Cloudflare D1 and Durable Objects from TypeScript
oxilite-cli The oxilite command and a SPARQL endpoint like oxigraph serve
oxilite-cypher, oxilite-datalog openCypher and Datalog over the same data
oxilite-jsonld, oxilite-vc JSON-LD documents and Verifiable Credentials

License

Dual-licensed under MIT or Apache-2.0, at your option, like Oxigraph.

Metadata

Release files for oxilite 0.9.0

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

Source distribution (sdist)

Source distribution for oxilite 0.9.0
File Size Uploaded
oxilite-0.9.0.tar.gz 612.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for oxilite 0.9.0
File
oxilite-0.9.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
oxilite-0.9.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
oxilite-0.9.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details
oxilite-0.9.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
oxilite-0.9.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
oxilite-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 57.5 MB

Release files / oxilite-0.9.0.tar.gz

Download URL oxilite-0.9.0.tar.gz
Size 612.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6484137f3e9a6c2c530e4772eb4df12edea984ab9abefccb7406ad8c2281c4b2
BLAKE2b-256 checksum
How to use checksums
f6319642047ed4a6964a6a14a7527dfa9e1f4e117a9a66f5b74e5a89b43377c1
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-win_amd64.whl

Download URL oxilite-0.9.0-cp39-abi3-win_amd64.whl
Size 9.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
58aa5f2b750a8ec1b639859574c89f0e4f671b281fcfd8ea1d3e3e15a10daeff
BLAKE2b-256 checksum
How to use checksums
c5495c3ba0a23605169433c60d34cd707b7481bf306955d94894b5a9a495320b
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL oxilite-0.9.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 10.0 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e2d0a5a06be415b155586b1af3de9bc3c9a3c010e3495c97a9aad0721dffdedb
BLAKE2b-256 checksum
How to use checksums
e1a78d0c08211cb202c2bb4ee70dc2f7b52c2df6a5bf3d9c50c1e4cce232176c
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL oxilite-0.9.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 9.3 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
bf3c4968c8ce47a25c02b19bc7a06750d7c72a096741ca0daf8a2797b87c3618
BLAKE2b-256 checksum
How to use checksums
144c0f5366da0bbdc4590d87404d91baab7f42b1541564cc0026ff38ca6919ef
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL oxilite-0.9.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 9.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
05353dbf43671a8981a6e62e30b059c8c41ce568fbf2818343b052d2aaad94ad
BLAKE2b-256 checksum
How to use checksums
bb041ef9ab1d761bc2af01137cb116b46d66a0e018a70fa3f71feba7c7c9eab8
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL oxilite-0.9.0-cp39-abi3-macosx_11_0_arm64.whl
Size 8.9 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
63a26910ea1dc7c135bf348ffc553189db0bcb5e88ec95014fa38afe81c3aad0
BLAKE2b-256 checksum
How to use checksums
1f855586fcf587ca79017ca3ed9cc7e2f1d5a50f406e88df876a83b497e60fcf
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 29, 2026.

Transparency log

Release files / oxilite-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL oxilite-0.9.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 9.5 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5c01784024055163b8b8839692d757d33bf76fb16e73dcd34d58b381454a3d45
BLAKE2b-256 checksum
How to use checksums
d65945e6f88cdce0946e37d4e046336e15f4b7db2712ff8692453227dfbe565e
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 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.1

7 release files

This release

0.9.0 This release

7 release files

0.8.0

7 release files

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