Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2014 18:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import groovy.sparql.*
// SPARQL 1.0 or 1.1 endpoint
def sparql = new Sparql(endpoint:"http://localhost:1234/testdb/query", user:"user", pass:"pass")
def query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 4"
// sparql result variables projected into the closure delegate
sparql.each query, {
println "${s} : ${p} : ${o}"
// Run an update query
def updateQuery = """
PREFIX dc: <>
INSERT { <http://example/egbook> dc:title "This is an example title5" } WHERE {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment