-
Notifications
You must be signed in to change notification settings - Fork 578
Created script sparqluery. #3290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.x
Are you sure you want to change the base?
Conversation
Try handling to mirror that of rdfpipe. Choosing argparse over optargs as described in documentation of optargs. support for multiple local files, single remote and stdin. remote support auth. Access to different remote storetype. Output will controlled by --format. Will either choose ResultParser or Parser plugins. Help will show extra help to the selected Parser. added test_sparqlquery for DESCRIBE ASK SELECT and CONSTRUCT query. Also testing for sparql endpoint with mock endpoint. Test for BerkeleyDB.
|
example help output: >>>python -m rdflib.tools.sparqlquery
usage: sparqlquery [-q QUERY] [--queryfile QUERYFILE] [--format FORMAT] [-w]
[--help] [--username USERNAME] [--password PASSWORD]
[--remote-storetype REMOTE_STORETYPE]
endpoint [endpoint ...]
A commandline tool for querying with sparql
on local files and remote sparql endpoints with custom serialization.
example usage:
'''bash
sparqlquery path/to/data.ttl -q "SELECT ?x WHERE {?x a foaf:Person. }"
rdfpipe test.ttl | sparqlquery - -q "SELECT ?x WHERE {?x a foaf:Person. }" --format json
sparqlquery data.ttl -q "ASK {:john a foaf:Person}" --format xml | grep true
sparqlquery path/to/data.ttl --query-file query.rq
sparqlquery data1.ttl data2.ttl -q "DESCRIBE <http://example.com/john>" --format turtle:+spacious
sparqlquery http://example.com/sparqlendpoint --query-file query.rq
sparqlquery http://example.com/sparqlendpoint --query-file query.rq --username user --password secret
sparqlquery /pyth/to/berkeley.db -q "SELECT ?x WHERE {?x a foaf:Person. }" --remote-storetype BerkeleyDB
'''
Tip: You can check the truth value for an ASK query, by regex in stdout for 'true'
or 'false'.
positional arguments:
endpoint Endpoints for sparql query. Can be set to multiple files.
Reads from stdin if '-' is given.
options:
-q, --query QUERY Sparql query. Cannot be set together with --queryfile.
--queryfile QUERYFILE
File from where the sparql query is read. Cannot be set
together with -q/--query
--format FORMAT Print sparql result in given format. Defaults to 'json' on
SELECT, to 'xml' on ASK and to 'turtle' on DESCRIBE and
CONSTRUCT. Keywords as described in epilog can be given
after format like: FORMAT:(+)KW1,-KW2,KW3=VALUE.
-w, --warn Output warnings to stderr (by default only critical
errors).
--help show help message and exit. Also prints information about
given format.
--username USERNAME Username used during authentication.
--password PASSWORD Password used during authentication.
--remote-storetype REMOTE_STORETYPE
You can specify which storetype should be used. Can only be
set, when using a single endpoint and not stdin. Will
default to 'SparqlStore' when endpoint is an
internetaddress.
For more customization for format 'json' use `pydoc rdflib.plugins.sparql.results.jsonresults.JSONResultSerializer.serialize`. Further keywords might be valid.
the following arguments are required: endpoint |
…t on python version.
|
Im not sure, why validation fails on windows. |
|
I've pushed a couple of commits to fix some of the failing tests @WhiteGobo. I think windows absolute paths were being interpreted as valid URLs. Fixed in 624dbcf There was also a separate import error with pyparsing. For v7 of RDFLib, the minimum pyparsing version we support is 2.1.0 as indicated by rdflib/devtools/constraints.min Line 5 in 3c9d9da
In pyparsing v2, it has a different package structure. I've added handling for it now in 380bbe5 |
|
Thx, the |
Try handling to mirror that of rdfpipe. Choosing argparse over optargs as described in documentation of optargs. support for multiple local files, single remote and stdin. remote support auth. Access to different remote storetype. Output will controlled by --format. Will either choose ResultParser or Parser plugins. Help will show extra help to the selected Parser. added test_sparqlquery for DESCRIBE ASK SELECT and CONSTRUCT query. Also testing for sparql endpoint with mock endpoint. Test for BerkeleyDB.
…t on python version.
This script doesnt support update methods like INSERT or DELETE.
Try handling to mirror that of rdfpipe. Choosing argparse over optargs as described in documentation of optargs.
support for multiple local files, single remote and stdin. remote support auth. Access to different remote storetype.
Output will controlled by --format. Will either choose ResultParser or Parser plugins. Help will show extra help to the selected Parser.
added test_sparqlquery for DESCRIBE ASK SELECT and CONSTRUCT query. Also testing for sparql endpoint with mock endpoint. Test for BerkeleyDB.
Summary of changes
Checklist
Default to readable output
Testing for
Checked that all tests and type checking passes.
If the change adds new features or changes the RDFLib public API:
./examples.If the change has a potential impact on users of this project:
Considered granting push permissions to the PR branch,
so maintainers can fix minor issues and keep your PR up to date.