Skip to main content

ProGraph

ProGraph answers SPARQL 1.1 queries over tables you already have. You give it a mapping (R2RML or YAML) from tables to RDF terms; each query is translated to one SQL statement that your database runs. Nothing is copied or loaded: the data stays where it is, and ProGraph does not write to your tables.

Install

Python 3.11 or later:

pip install "prograph[duckdb]"

Extras, from pyproject.toml; install the ones you use.

Extra Adds
duckdb DuckDB and pandas: the default engine over DataFrames, and DuckDB databases
pandas pandas 2
postgresql the ADBC PostgreSQL driver
oracle oracledb
spark PySpark 4.1 or later
databricks the Databricks SQL connector and SDK
databricks-rt the connector's kernel path, for Lakehouse RT warehouses
shacl pyshacl, for engine.validate_shapes()
endpoint the SPARQL Protocol server, prograph serve
mcp the MCP server and the model client its ask tool uses
cli prograph load-ttl and prograph infer-schema
nlp, nlp-databricks, nlp-langchain the natural-language interface
genie the Databricks Genie integration
logging, ui, graphql structlog; the web UI; GraphQL (experimental)

MySQL and SQL Server have no extra: install mysql-connector-python or pyodbc yourself (SQL Server also needs the ODBC Driver 18).

Quickstart

A DuckDB table, a YAML mapping and one query:

import duckdb
from prograph import ProGraph
from prograph.config import load_config

con = duckdb.connect()
con.execute("CREATE TABLE people (id INTEGER, name VARCHAR, age INTEGER)")
con.execute("INSERT INTO people VALUES (1, 'Alice', 30), (2, 'Bob', 25)")

open("graph.yaml", "w").write("""
version: "1.0"
graph: {name: people}
sources:
  people: {table: people}
nodes:
  - label: Person
    source: people
    id_column: id
    iri_template: "http://example.org/person/{id}"
    class_iri: "http://example.org/Person"
    properties: {name: name, age: age}
rdf: {vocab_iri: "http://example.org/", auto_generate: true}
""")
engine = ProGraph(schema=load_config("graph.yaml").to_schema(), connection=con)

engine.execute("""
PREFIX ex: <http://example.org/>
SELECT ?name ?age WHERE { ?p a ex:Person ; ex:name ?name ; ex:age ?age . FILTER(?age > 26) }
""", language="sparql", return_type="list")
# [{'name': 'Alice', 'age': 30}]

ProGraph.from_r2rml(path, connection=con) reads an R2RML mapping instead. More: quickstart, map your tables, R2RML tutorial.

Reasoning

Pass an ontology (ontology=) and reasoning is on. The RDFS core is always on with an ontology. profile="ql", the default, answers OWL 2 QL by rewriting the query: nothing is stored. profile="rl" with an owned store (store=) materializes OWL 2 RL facts into ProGraph's own tables, never yours; a query reads them only where every mapped table is provably unchanged since the run that made them. An ontology and data that contradict each other raise InconsistentOntologyError unless inconsistency="report". owl:imports is read from local files only. See OWL and ontology and OWL 2 RL.

Backends

Backend Install SPARQL Owned store, profile="rl"
DuckDB, over pandas DataFrames or a DuckDB database duckdb yes yes
PostgreSQL (also Lakebase, over ADBC) postgresql yes yes
Spark (a SparkSession) spark yes yes, with Delta Lake
Databricks SQL warehouse databricks yes yes
Oracle oracle yes no
MySQL 8.0+ mysql-connector-python yes no
SQL Server pyodbc yes no

PostgreSQL, MySQL, SQL Server and Oracle are checked behind DuckDB, Databricks and Spark: a fault found only on one of them waits for a later pass. What differs per backend: backends, what differs by backend.

Cypher

Cypher queries run on every engine, with no option: engine.execute(query, language="cypher").

  • Mapping. Cypher needs a YAML mapping: an R2RML mapping has no property-graph view and raises PropertyGraphViewError; query it with SPARQL.
  • Ontology. Cypher applies the ontology's class and property hierarchies only (subclass, sub-property, equivalent class and property). The first Cypher query on an engine whose ontology states other axioms (domain and range, inverses, symmetric and transitive properties, owl:sameAs, RL facts, individuals) warns once (CypherOntologyWarning); SPARQL applies them.
  • Writes. CREATE, SET, REMOVE, DELETE and MERGE write into the owned store (store=), never a mapped table; with no store they raise CypherWriteRefusedError. A label a table maps, or an inferred superclass of one, or a label the ontology makes a subclass of another, is refused.
  • Nodes. A node is the map {id, labels, properties}; its id is its IRI, and so are id(n) and elementId(n). A node mapping's key columns are properties under their column names (n.id). A property no mapping declares is null.
  • Speed. A Cypher plan runs as translated, without the rewrites SPARQL plans get. A pattern that a second MATCH joins back to nodes the first bound (MATCH (a)-[:KNOWS]->(b) MATCH (a)-[:LIKES]->(p)<-[:LIKES]-(b)) can take minutes on large tables: its joins run in the order written, over every type a relationship's table gives. On LDBC SF1, 3 of 200 Cypher queries ran past 2 minutes on DuckDB; one of them, written in SPARQL, took half a second. Write such a query in SPARQL until this is fixed.
  • Checked. The openCypher TCK gave 0 wrong answers across the scenarios run for 1.3.0: 2,880 on DuckDB and on Spark; 2,658 on PostgreSQL, where 222 more are refused by name (values of several types in one column, lists of lists, paths held as values); 2,849 of the 2,880 on a Databricks SQL warehouse, where the other 31 hold values it has no type for (TIME, TIME WITH TIME ZONE, nanoseconds). Of the TCK's 3,897 scenarios, 314 are not built (refused by name) and the rest expect an error or a setup the test harness cannot load. MySQL, SQL Server and Oracle run Cypher unchecked.
  • Natural-language ask writes SPARQL by default, or Cypher (language="cypher"); it never writes data.

See Choosing a language and the conformance choices.

Endpoint, MCP and ask

prograph serve --config graph.yaml serves the SPARQL 1.1 Protocol; with --mcp it also serves MCP tools at /mcp, including ask, which turns a question into SPARQL (or Cypher) with a model, runs it, and retries with the error if it fails. See the endpoint and agents.

More

Metadata

Release files for prograph 1.3.3

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

Source distribution (sdist)

Source distribution for prograph 1.3.3
File Size Uploaded Provenance Actions
prograph-1.3.3.tar.gz 1.4 MB Without provenance Details for prograph-1.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prograph 1.3.3
File Interpreter ABI Platform Actions
prograph-1.3.3-py3-none-any.whl Python 3 none any Details for prograph-1.3.3-py3-none-any.whl

Total release size: 2.9 MB

Release files / prograph-1.3.3.tar.gz

Download URL prograph-1.3.3.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
98a768d6d76aacd79d2631d493ea59883b86cde0ce26ca3ed2c39e0ffa5ae069
BLAKE2b-256 checksum
How to use checksums
5ebbc31b77eee7374c86d90c89c0d3a10e0da904232db48a80aa0b0fde95c2a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / prograph-1.3.3-py3-none-any.whl

Download URL prograph-1.3.3-py3-none-any.whl
Size 1.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2bbd410a34fb64f61aa2b374ac32992dde7300129c6ecee03edc8064f7234292
BLAKE2b-256 checksum
How to use checksums
3a6ac6cf1fa6129498e37253183d0f6ccb61036afc6e46f2da0668ad80f43534
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Security for prograph 1.3.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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