RDFLib / sparqlwrapper

A wrapper for a remote SPARQL endpoint
https://sparqlwrapper.readthedocs.io/
Other
513 stars 121 forks source link

Add cli options #185

Closed eggplants closed 2 years ago

eggplants commented 2 years ago

I have added options to specify request method (-m, --method) and HTTPS auth (-a, --auth, -u, --username, -p, --password) and some testcases.

$ rqw -h
usage: rqw [-h] (-f FILE | -Q QUERY) [-F FORMAT] [-e URI] [-m METHOD] [-a AUTH] [-u ID] [-p PW] [-q] [-V]

sparqlwrapper CLI

optional arguments:
  -h, --help                  show this help message and exit
  -f FILE, --file FILE        query with sparql file (stdin: -) (default: None)
  -Q QUERY, --query QUERY     query with string (default: None)
  -F FORMAT, --format FORMAT  response format (default: json)
  -e URI, --endpoint URI      sparql endpoint (default: http://dbpedia.org/sparql)
  -m METHOD, --method METHOD  request method (default: None)
  -a AUTH, --auth AUTH        HTTP auth (default: None)
  -u ID, --username ID        username for auth (default: guest)
  -p PW, --password PW        password for auth (default: )
  -q, --quiet                 supress warnings (default: False)
  -V, --version               show program's version number and exit

allowed FORMAT:
  - json
  - xml
  - turtle
  - n3
  - rdf
  - rdf+xml
  - csv
  - tsv
  - json-ld

allowed METHOD:
  - POST
  - GET

allowed AUTH:
  - BASIC
  - DIGEST

$ rqw -e https://lindas.admin.ch/query -Q "SELECT DISTINCT ?x WHERE { ?x ?y ?z . } LIMIT 1" -m POST
x
http://classifications.data.admin.ch/canton/bl