Teknik Informatika/SPARQL
import sparql q = (""" SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q5; wdt:P166 wd:Q1369309; wdt:P21 wd:Q6581072. SERVICE wikibase:label { bd:serviceParam wikibase:language "en,id". } } """) result = sparql.query('https://query.wikidata.org/bigdata/namespace/wdq/sparql',q) for row in result: values = sparql.unpack_row(row) print(values[0],values[1])
Seperti ini, templatenya kalau pakai Python. Pakai library sparql-client 3.8.
pip install sparql-client
- Repo Github : https://github.com/eea/sparql-client
- Pypi : https://pypi.org/project/sparql-client/
Select _ where
suntingSELECT ?bookLabel ?authorLabel WHERE { ?book wdt:P7937 wd:Q8261. ?book wdt:P495 wd:Q252. ?book wdt:P50 ?author SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". } }