Skip to content

Conversation

@WhiteGobo
Copy link
Contributor

@WhiteGobo WhiteGobo commented Oct 27, 2025

Try handling to mirror that of rdfpipe. Choosing argparse over optargs as described in documentation of optargs.

support for multiple local files and single remote. remote support authentication (--username and --password).

Output will be either controlled by --format.
Sparql query can be provided by input with -q/--query or with a file with --queryfile.

Summary of changes

Created script sparqlquery and provided it via pyproject.toml
Issue for this feature #3280

Checklist

I can add addional things to the checklist, if i forgot something.

  • Default to readable output

  • Testing for

    • works on local files from command line
    • on local files
    • on sparql remotes
    • SELECT
    • ASK
    • DESCRIBE
    • INSERT
    • authentication
  • Checked that all tests and type checking passes.

  • If the change adds new features or changes the RDFLib public API:

    • Created an issue to discuss the change and get in-principle agreement.
    • Considered adding an example in ./examples.
  • If the change has a potential impact on users of this project:

    • Added or updated tests that fail without the change.
    • Updated relevant documentation to avoid inaccuracies.
    • Considered adding additional documentation.
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

Try handling to mirror that of rdfpipe. Choosing argparse over optargs as described in documentation of optargs.

support for multiple local files and single remote. remote support auth.

Output will be either controlled by --format or by --print.
--format will use builtin plugins.
--print should give easy access on control for output. class PrettyTerm
describes how terms are formatted.
@WhiteGobo
Copy link
Contributor Author

example usage:

sparqlquery path/to/data.ttl -q "SELECT ?x WHERE {?x a foaf:Person. }"
sparqlquery path/to/data.ttl -q "SELECT ?x WHERE {?x a foaf:Person. }" --format json     
sparqlquery path/to/data.ttl -q "SELECT ?x WHERE {?x a foaf:Person. }" --print "custom print: {x.value}" --only-first
sparqlquery path/to/data.ttl --query-file query.spl
sparqlquery data1.ttl data2.ttl --query-file query.spl
sparqlquery http://example.com/sparqlendpoint --query-file query.spl
sparqlquery http://example.com/sparqlendpoint --query-file query.spl --username user --password secret 

@WhiteGobo WhiteGobo closed this Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant