sparql_fdw is experimantal code, use it at your own risk. But please consider to open a bug report on the Github repository, if you stumble upon something, that doesn't work as expected.
As the original multicorn sources are somewhat outdated, use multicorn2 instead. Please follow the installation guide on https://github.com/pgsql-io/multicorn2
yum install -y epel-release
yum install -y python3-setuptools git python3-pip python3-dateutil
pip3 install --break-system-packages --upgrade pip
pip3 install --break-system-packages SPARQLWrapper python-dateutil
git clone https://github.com/al1radix/sparql_fdw.git
cd sparql_fdw
python3 setup.py install
sudo apt install -y python3-setuptools git python3-pip python3-dateutil
sudo pip3 install --break-system-packages --upgrade pip
sudo pip3 install --break-system-packages SPARQLWrapper python-dateutil
pip3 install --break-system-packages python-dateutil
git clone https://github.com/al1radix/sparql_fdw.git
cd sparql_fdw
sudo pip3 install --break-system-packages .
create extension multicorn;
CREATE server wikidata foreign data wrapper multicorn
options ( wrapper 'sparqlfdw.SparqlForeignDataWrapper', endpoint 'https://query.wikidata.org/sparql');
CREATE server dbpedia foreign data wrapper multicorn options ( wrapper 'sparqlfdw.SparqlForeignDataWrapper', endpoint 'http://dbpedia.org/sparql' );
- matching is done between table's column names and sparql selected variables names
-- eyes colors from wikidata
CREATE FOREIGN TABLE eyes ( "eyeColorLabel" json, count int, rien text )
server wikidata options ( sparql '
SELECT ?eyeColorLabel (COUNT(?human) AS ?count)
WHERE { ?human wdt:P31 wd:Q5. ?human wdt:P1340 ?eyeColor.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
GROUP BY ?eyeColorLabel
')
;
The actual implementation is simplist and dosn't push down restriction, group by, order by nor limit to sparql