RDF
Transactional SQL tables stored as RDF graphs
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/rdf/index.md to help me query RDF with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Count RDF statements by graph
Example output · captured
- Connector release
- v0.3.2
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT graph, count(*) AS statements
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph
| graph | statements |
|---|---|
| <urn:vgi:rdf:catalog> | 2 |
Quick start
Choose where to run RDF, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'rdf' AS rdf (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-rdf-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'rdf' AS rdf (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-rdf:0.3.2'
);
3. Run a query
SELECT graph, count(*) AS statements
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'rdf' AS rdf
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT graph, count(*) AS statements
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph
Query Farm operates RDF for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use rdf as the catalog alias for the query below.
4. Run a query
SELECT graph, count(*) AS statements
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph
Technical details
- Verified connector release
- v0.3.2
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'rdf' AS rdf (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-rdf-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'rdf' AS rdf (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-rdf:0.3.2'
);
Overview
Transactional SQL tables stored as RDF in an Oxigraph dataset, so the same data can be queried as ordinary SQL rows or with local SPARQL and graph traversal.
RDF database worker
Persistent SQL tables backed by an Oxigraph RDF dataset. Supports SELECT, INSERT, UPDATE, DELETE, CREATE/DROP TABLE, schemas, RETURNING, defaults, NOT NULL, primary/unique keys and immediate foreign keys. Native SQL runs in the host engine; data and table definitions persist as RDF. Transactions use immutable snapshots and reject concurrent writer conflicts. Attach with database set to a durable directory, or omit it for a temporary database. Query the same data as typed SQL rows or RDF terms using local read-only SPARQL and bounded graph traversal. Stable resource identities connect the two query models. Foreign keys produce transactional resource-to-resource RDF edges. The backend enforces CHECK constraints, but the tested SQL engines cannot send native CHECK definitions.
SQL data and definitions live in an Oxigraph dataset. The database directory contains immutable committed generations and private transaction workspaces. Commit publishes a complete generation; rollback discards private writes.
Sources and references
- Oxigraph and its Python binding pyoxigraph — the RDF store and SPARQL engine underneath
- RDF 1.1 Concepts — the IRI, literal, datatype and language-tag model the stored rows and returned terms follow
- SPARQL 1.1 Query Language — the query language
rdf_sparqlaccepts
ATTACH options
- database
- Persistent RDF database directory; empty creates a temporary database.VARCHAR
- read_only
- Reject every data or schema mutation on this attachment.BOOLEAN
Catalog
Everything rdf exposes once attached — read straight from the worker's
released build.
main 6 functions
SQL tables in schema 'main' and RDF inspection tools.
Schema examples (2)
Count RDF statements by graph
SELECT graph, count(*) AS statements
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph;
| graph | statements |
|---|---|
| <urn:vgi:rdf:catalog> | 2 |
Return inline SPARQL VALUES as IRI and language-tagged literal terms
SELECT person.value AS person, name.value AS name, name.language AS language
FROM rdf.main.rdf_sparql('SELECT ?person ?name WHERE { VALUES (?person ?name) { (<urn:example:ada> "Ada"@en) (<urn:example:grace> "Grace Hopper"@en) } }')
ORDER BY name;
rdf_neighbors (node VARCHAR, direction := VARCHAR, graph_iri := VARCHAR, max_rows := BIGINT, predicate_iri := VARCHAR, timeout_ms := BIGINT)
Find outgoing or incoming RDF relationship edges for one node
An IRI with no stored relationships has no neighbors, so this count is intentionally 0
SELECT count(*) AS edges
FROM rdf.main.rdf_neighbors('urn:example:absent', direction := 'both');
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SET VARIABLE ada_iri = (SELECT __rdf_iri FROM rdf.main.rdf_rows('main', 'people') WHERE name = 'Ada');
SELECT count(*) AS referencing_orders FROM rdf.main.rdf_neighbors(getvariable('ada_iri'), direction := 'in');
ROLLBACK;
SELECT count(*) FROM rdf.main.rdf_neighbors('urn:example:absent');
rdf_quads (graph_iri := VARCHAR)
Inspect the persisted RDF dataset as subject, predicate, object and graph terms
Count stored RDF statements by named graph
SELECT graph, count(*) AS triples
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph;
Count metadata statements by predicate
SELECT predicate, count(*) AS statements
FROM rdf.main.rdf_quads(graph_iri := 'urn:vgi:rdf:catalog')
GROUP BY predicate
ORDER BY predicate;
Count RDF schema resources
SELECT count(*) AS schemas
FROM rdf.main.rdf_quads()
WHERE predicate = '<urn:vgi:rdf:schemaName>';
1 more example
SELECT count(*) AS main_schemas
FROM rdf.main.rdf_quads()
WHERE predicate = '<urn:vgi:rdf:schemaName>' AND object = '"main"';
rdf_reachable (node VARCHAR, direction := VARCHAR, graph_iri := VARCHAR, max_depth := BIGINT, max_rows := BIGINT, predicate_iri := VARCHAR, timeout_ms := BIGINT)
Traverse RDF relationships with cycle detection and bounded minimum-depth results
An IRI with no stored relationships reaches no nodes, so this count is intentionally 0
SELECT count(*) AS nodes
FROM rdf.main.rdf_reachable('urn:example:absent', max_depth := 3);
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SET VARIABLE order_10_iri = (SELECT __rdf_iri FROM rdf.main.rdf_rows('main', 'orders') WHERE id = 10);
SELECT depth, count(*) AS nodes FROM rdf.main.rdf_reachable(getvariable('order_10_iri'), direction := 'both', max_depth := 3) GROUP BY depth ORDER BY depth;
ROLLBACK;
SELECT count(*)
FROM rdf.main.rdf_reachable('urn:example:absent', max_depth := 3);
rdf_rows (schema_name VARCHAR, table_name VARCHAR)
Read a SQL table with its stable RDF row IRI for graph joins
Find the RDF row IRI of each person; fails unless a people table with a name column exists, as in the executable examples
SELECT name, __rdf_iri
FROM rdf.main.rdf_rows('main', 'people')
ORDER BY name;
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SELECT name, starts_with(__rdf_iri, 'urn:vgi:rdf:table:') AS has_row_iri FROM rdf.main.rdf_rows('main', 'people') ORDER BY name;
ROLLBACK;
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SELECT p.name, count(g.source_row) AS incoming_references FROM rdf.main.rdf_rows('main', 'people') AS p LEFT JOIN rdf.main.rdf_sparql('SELECT ?source_row ?target_row WHERE { GRAPH <urn:vgi:rdf:relationships> { ?source_row ?relationship ?target_row } }') AS g ON g.target_row.value = p.__rdf_iri GROUP BY p.name ORDER BY p.name;
ROLLBACK;
rdf_sparql (query VARCHAR, max_rows := BIGINT, timeout_ms := BIGINT, union_default := BOOLEAN)
Query RDF with bounded local SPARQL and join the results with SQL tables
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
-
kindVARCHAR
-
valueVARCHAR
-
datatypeVARCHAR
-
languageVARCHAR
Check whether the RDF catalog contains statements
SELECT answer
FROM rdf.main.rdf_sparql('ASK { GRAPH <urn:vgi:rdf:catalog> { ?s ?p ?o } }');
Return inline SPARQL VALUES as IRI and language-tagged literal terms
SELECT person.value AS person, name.value AS name, name.language AS language
FROM rdf.main.rdf_sparql('SELECT ?person ?name WHERE { VALUES (?person ?name) { (<urn:example:ada> "Ada"@en) (<urn:example:grace> "Grace Hopper"@en) } }')
ORDER BY name;
rdf_tables (schema_name := VARCHAR)
Discover RDF identifiers for SQL tables, columns and foreign-key relationships
Count mapped tables, columns and foreign keys; a fresh database has none, so this is 0 until you create a table
SELECT count(*) AS mapped_objects FROM rdf.main.rdf_tables();
SELECT count(*) FROM rdf.main.rdf_tables();
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SELECT kind, count(*) AS objects FROM rdf.main.rdf_tables() GROUP BY kind ORDER BY kind;
ROLLBACK;
2 more examples
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SELECT t.schema_name, t.table_name, count(q.subject) AS statements FROM rdf.main.rdf_tables() AS t LEFT JOIN rdf.main.rdf_quads() AS q ON q.graph = '<' || t.graph_iri || '>' WHERE t.kind = 'table' GROUP BY t.schema_name, t.table_name ORDER BY t.schema_name, t.table_name;
ROLLBACK;
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SELECT fk.schema_name, fk.table_name AS referencing_table, target.table_name AS referenced_table, count(q.subject) AS edges FROM rdf.main.rdf_tables() AS fk JOIN rdf.main.rdf_tables() AS target ON target.kind = 'table' AND target.iri = fk.target_iri LEFT JOIN rdf.main.rdf_quads(graph_iri := 'urn:vgi:rdf:relationships') AS q ON q.predicate = '<' || fk.iri || '>' WHERE fk.kind = 'foreign_key' GROUP BY fk.schema_name, fk.table_name, target.table_name ORDER BY fk.schema_name, referencing_table, referenced_table;
ROLLBACK;
Try these queries
Return inline SPARQL VALUES as IRI and language-tagged literal terms
SELECT person.value AS person, name.value AS name, name.language AS language
FROM rdf.main.rdf_sparql('SELECT ?person ?name WHERE { VALUES (?person ?name) { (<urn:example:ada> "Ada"@en) (<urn:example:grace> "Grace Hopper"@en) } }')
ORDER BY name
Uses rdf_sparql
Count mapped tables, columns and foreign keys; a fresh database has none, so this is 0 until you create a table
SELECT count(*) AS mapped_objects FROM rdf.main.rdf_tables()
Uses rdf_tables
An IRI with no stored relationships reaches no nodes, so this count is intentionally 0
SELECT count(*) AS nodes
FROM rdf.main.rdf_reachable('urn:example:absent', max_depth := 3)
Uses rdf_reachable
Count nodes by distance from order 10: its buyer Ada at depth 1 and Ada's other order at depth 2; uses a sample of people (Ada, Grace, Linus) and orders 10 and 11 bought by Ada and 12 by Grace, rolled back after
BEGIN;
CREATE TABLE rdf.main.people(id INTEGER PRIMARY KEY, name VARCHAR);
CREATE TABLE rdf.main.orders(id INTEGER PRIMARY KEY, buyer INTEGER REFERENCES rdf.main.people(id));
INSERT INTO rdf.main.people VALUES (1, 'Ada'), (2, 'Grace'), (3, 'Linus');
INSERT INTO rdf.main.orders VALUES (10, 1), (11, 1), (12, 2);
SET VARIABLE order_10_iri = (SELECT __rdf_iri FROM rdf.main.rdf_rows('main', 'orders') WHERE id = 10);
SELECT depth, count(*) AS nodes FROM rdf.main.rdf_reachable(getvariable('order_10_iri'), direction := 'both', max_depth := 3) GROUP BY depth ORDER BY depth;
ROLLBACK;
Count stored RDF statements by named graph
SELECT graph, count(*) AS triples
FROM rdf.main.rdf_quads()
GROUP BY graph
ORDER BY graph
Uses rdf_quads
An IRI with no stored relationships has no neighbors, so this count is intentionally 0
SELECT count(*) AS edges
FROM rdf.main.rdf_neighbors('urn:example:absent', direction := 'both')
Uses rdf_neighbors
14 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- Use rdf_sparql to ASK whether urn:vgi:rdf:catalog contains statements. Return answer.
- Count the SQL-to-RDF mappings returned by rdf_tables. Return one count.
- Count outgoing edges from urn:example:absent with rdf_neighbors. Return one count.
- Count nodes reachable from urn:example:absent within three edges using rdf_reachable.
- Create rdf.main.agent_people(name VARCHAR), insert Ada, then use rdf_rows to return name and whether its __rdf_iri starts with urn:vgi:rdf:table:.
RDF is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Elasticsearch
Databases & messaging
Query Elasticsearch and OpenSearch indices as SQL tables with consistent deep pagination
NATS
Databases & messaging
NATS server monitoring and read-only JetStream streams, consumers, messages, KV and object stores
OData
Databases & messaging
Read OData v2/v4 REST services from SQL, with $filter pushdown, automatic paging and metadata discovery