[redland-dev] API wish - bind identifiers in queries

tobutaz at gmail.com tobutaz at gmail.com
Mon May 28 22:17:41 BST 2007


I'm looking for easier ways to run SPARQL queries.
For example, if I pass around a node instance in my code, I'd like a
simple way to query what properties or neighbours it has in the graph.

I've also used rdflib for a while (writing in python), and it has a
nice API for this.
Besides graph.execute(SPARQLQuery('SELECT *')), you can add a bindings
parameter and a namespaces parameter:

graph.execute(SPARQLQuery(
  'SELECT ?friend WHERE { ?sam x:knows ?friend }'),
  bindings={ 'sam': samNode }, namespaces={ 'x': nsNode })

When the query is run, ?sam and x:knows exist within the query.
There is really no other way to do that without extra knowledge about
samNode and rewriting the query.

At the moment, it wouldn't be easy to do something like that as an API consumer.
I've been doing the namespace thing by wrapping the query.execute API
into another that does some printf to have the query explicitly name
the prefixes (string processing for queries just reminds me of SQL
injection, but it works).
I'm at a loss for a way to do this printf magic for an RDF.Node
object, especially a blank (reading that nearby thread).

Hope I got anyone interested enough to write support for this on the
C-side, it really would make redland more useful.

-- 
My English is poor, but my tailor is rich.


More information about the redland-dev mailing list