sesamerdf4j

How can I use the RDF4J console to programmatically create a repository?


As explained here, it is easy to clear an existing repository and load new datasets. However, due to the dialogue nature of the create command, I fail to see how I can set up a repo just using a script. Moreover, the REST API documentation seems to omit the possibility of creating a repo; only to remove it.


Solution

  • Just put the expected inputs for the dialogs in your script, one on each line. For example to create an in-memory repositry called 'test-script', firing a query against it, then closing it:

    create memory.
    test-script
    testing using a script
    10000
    true
    0
    org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory
    open test-script. 
    select * where {?s ?p ?o }.
    close.
    quit.
    

    As for creating a repo via the REST API, that's possible, but somewhat underdocumented (mainly because it is cumbersome). If you need programmatic access to this kind of stuff, it's far easier to use the RDF4J Java APIs.