Difference between revisions of "Snapquery"
Jump to navigation
Jump to search
Line 67: | Line 67: | ||
qlever-wikidata:https://qlever.cs.uni-freiburg.de/wikidata:https://qlever.cs.uni-freiburg.de/api/wikidata(POST) | qlever-wikidata:https://qlever.cs.uni-freiburg.de/wikidata:https://qlever.cs.uni-freiburg.de/api/wikidata(POST) | ||
</source> | </source> | ||
+ | === Run Query === | ||
+ | <source lang='bash' highlight='1'> | ||
+ | snapquery -qn cats --limit 10 -f mediawiki | ||
+ | </source> | ||
+ | ==== cats ===== | ||
+ | |||
+ | ===== query ===== | ||
+ | <source lang='sparql'> | ||
+ | |||
+ | SELECT ?item ?itemLabel | ||
+ | WHERE { | ||
+ | ?item wdt:P31 wd:Q146. # Must be a cat | ||
+ | SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } | ||
+ | } | ||
+ | |||
+ | </source> | ||
+ | |||
+ | [https://query.wikidata.org/#%0ASELECT%20%3Fitem%20%3FitemLabel%0AWHERE%20%7B%0A%20%20%3Fitem%20wdt%3AP31%20wd%3AQ146.%20%23%20Must%20be%20a%20cat%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D%0A try it!] | ||
+ | ===== result ===== | ||
+ | {| class="wikitable" style="text-align: left;" | ||
+ | |+ <!-- caption --> | ||
+ | |- | ||
+ | ! item !! itemLabel | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q378619 || CC | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q498787 || Muezza | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q677525 || Orangey | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q851190 || Mrs. Chippy | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q893453 || Unsinkable Sam | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q1050083 || Catmando | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q1185550 || Oscar | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q1201902 || Tama | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q1207136 || Dewey Readmore Books | ||
+ | |- | ||
+ | | http://www.wikidata.org/entity/Q1371145 || Socks | ||
+ | |} | ||
{{pip|snapquery}} | {{pip|snapquery}} |
Revision as of 05:54, 4 May 2024
OsProject
OsProject | |
---|---|
id | snapquery |
state | active |
owner | WolfgangFahl |
title | snapquery |
url | https://github.com/WolfgangFahl/snapquery |
version | 0.0.3 |
description | Frontend to Introduce Named Queries and Named Query Middleware to wikidata |
date | 2024-05-04 |
since | 2024-05-03 |
until |
Usage
Commandline
Help
snapquery -h
usage: snapquery [-h] [-a] [--apache APACHE] [-c] [-d]
[--debugServer DEBUGSERVER] [--debugPort DEBUGPORT]
[--debugRemotePath DEBUGREMOTEPATH]
[--debugLocalPath DEBUGLOCALPATH] [-l] [-i INPUT] [-rol]
[--host HOST] [--port PORT] [-s] [-V] [-ep ENDPOINTPATH]
[-en ENDPOINTNAME] [-le]
Introduce Named Queries and Named Query Middleware to wikidata
options:
-h, --help show this help message and exit
-a, --about show about info [default: False]
--apache APACHE create an apache configuration file for the given
domain
-c, --client start client [default: False]
-d, --debug show debug info [default: False]
--debugServer DEBUGSERVER
remote debug Server
--debugPort DEBUGPORT
remote debug Port
--debugRemotePath DEBUGREMOTEPATH
remote debug Server path mapping - remotePath - path
on debug server
--debugLocalPath DEBUGLOCALPATH
remote debug Server path mapping - localPath - path on
machine where python runs
-l, --local run with local file system access [default: False]
-i INPUT, --input INPUT
input file
-rol, --render_on_load
render on load [default: False]
--host HOST the host to serve / listen from [default: localhost]
--port PORT the port to serve from [default: 9862]
-s, --serve start webserver [default: False]
-V, --version show program's version number and exit
-ep ENDPOINTPATH, --endpointPath ENDPOINTPATH
path to yaml file to configure endpoints to use for
queries
-en ENDPOINTNAME, --endpointName ENDPOINTNAME
Name of the endpoint to use for queries - use
--listEndpoints to list available endpoints
-le, --listEndpoints show the list of available endpoints
List Endpoints
snapquery --listEndpoints
wikidata:https://query.wikidata.org:https://query.wikidata.org/sparql(POST)
qlever-wikidata:https://qlever.cs.uni-freiburg.de/wikidata:https://qlever.cs.uni-freiburg.de/api/wikidata(POST)
Run Query
snapquery -qn cats --limit 10 -f mediawiki
cats =
query
SELECT ?item ?itemLabel
WHERE {
?item wdt:P31 wd:Q146. # Must be a cat
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
result
item | itemLabel |
---|---|
http://www.wikidata.org/entity/Q378619 | CC |
http://www.wikidata.org/entity/Q498787 | Muezza |
http://www.wikidata.org/entity/Q677525 | Orangey |
http://www.wikidata.org/entity/Q851190 | Mrs. Chippy |
http://www.wikidata.org/entity/Q893453 | Unsinkable Sam |
http://www.wikidata.org/entity/Q1050083 | Catmando |
http://www.wikidata.org/entity/Q1185550 | Oscar |
http://www.wikidata.org/entity/Q1201902 | Tama |
http://www.wikidata.org/entity/Q1207136 | Dewey Readmore Books |
http://www.wikidata.org/entity/Q1371145 | Socks |
Installation
pip install snapquery
# alternatively if your pip is not a python3 pip
pip3 install snapquery
# local install from source directory of snapquery
pip install .
upgrade
pip install snapquery -U
# alternatively if your pip is not a python3 pip
pip3 install snapquery -U