sparql
Query SPARQL datasource with SQL
Repository
lacanoid/pgsparql
https://github.com/lacanoid/pgsparql
Source
pgsparql-1.0.tar.gz
pgsparql-1.0.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgsparql | 1.0 | UTIL | Apache-2.0 | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4470 | sparql | No | No | No | Yes | No | No | sparql |
| Related | plperl plperlu pgjq pgjwt gzip bzip zstd http pg_net pg_curl |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | pgsparql | plperl, plperlu |
| RPM | PIGSTY | 1.0 | 1817161514 | pgsparql_$v | - |
| DEB | PIGSTY | 1.0 | 1817161514 | postgresql-$v-pgsparql | - |
Build
You can build the RPM / DEB packages for pgsparql using pig build:
pig build pkg pgsparql # build RPM / DEB packages
Install
You can install pgsparql directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgsparql; # Install for current active PG version
pig ext install -y pgsparql -v 18 # PG 18
pig ext install -y pgsparql -v 17 # PG 17
pig ext install -y pgsparql -v 16 # PG 16
pig ext install -y pgsparql -v 15 # PG 15
pig ext install -y pgsparql -v 14 # PG 14
dnf install -y pgsparql_18 # PG 18
dnf install -y pgsparql_17 # PG 17
dnf install -y pgsparql_16 # PG 16
dnf install -y pgsparql_15 # PG 15
dnf install -y pgsparql_14 # PG 14
apt install -y postgresql-18-pgsparql # PG 18
apt install -y postgresql-17-pgsparql # PG 17
apt install -y postgresql-16-pgsparql # PG 16
apt install -y postgresql-15-pgsparql # PG 15
apt install -y postgresql-14-pgsparql # PG 14
Create Extension:
CREATE EXTENSION sparql CASCADE; -- requires: plperl, plperlu
Usage
Query SPARQL endpoints (e.g., DBpedia/Virtuoso) from PostgreSQL. SPARQL queries are compiled into Postgres views for use in SQL.
Get Properties of a Resource
SELECT * FROM sparql.get_properties('dbpedia', 'http://dbpedia.org/resource/Johann_Sebastian_Bach');
Get References to a Resource
SELECT * FROM sparql.get_references('dbpedia', 'http://dbpedia.org/resource/Johann_Sebastian_Bach');
Compile SPARQL Query into SQL View
SELECT sparql.compile_query(endpoint, identifier, sparql_query [, grouping]);
Parameters:
endpoint– default SPARQL endpoint nameidentifier– SQL identifier for the created function and viewsparql_query– the SPARQL query to compilegrouping– optional array of identifiers to group by (non-grouped columns are aggregated into arrays)
Example
SELECT sparql.compile_query('dbpedia', 'ludwig_van', $$
SELECT ?predicate, ?object
WHERE {
<http://dbpedia.org/resource/Ludwig_van_Beethoven> ?predicate ?object.
}
$$, '{predicate}');
-- Now query via the created view
SELECT * FROM ludwig_van;
This creates a function ludwig_van() and a view ludwig_van that queries the SPARQL endpoint and returns results as a SQL table.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.