Basic Example for how to write SPARQL query in c++

Hello friends,

sorry I don't know
I am new to the SPARQL database language so I need basic help. how to use the sparql queries in c++ meaning how to extract the data from turtle file using sparql queries in c++. I have installed RDF libraries and filled the turtle file only thing is how to extract turtle file data.

Last edited on
I don't have anything to say to your question. BUT WHY WOULD YOU PUT YOUR QUERY IN A CODE TAG ????
I don't know if this thead is alive, but maybe this will help you.

SPARQL (http://en.wikipedia.org/wiki/SPARQL) is not a database query language. There are bridges between semantic web and relational databases and SPARQL queries (as i know not all, but a very huge set) can be translated to SQL.

So the simpliest SPARQL query is probably this:

SELECT * WHERE {?s ?p ?o}

This query means, that you want to retrive all tripple patterns from some RDF Graph.

SPARQL supports much more. You can view the examples in SPARQL Specification (http://www.w3.org/TR/rdf-sparql-query/).

If you need more info, please ask.

I'm just curious, what are you going to do with this stuff?
Thank so much for your help. so please see what I want is suppose I have turtle file name called example.ttl which contain some data which in turtle format.

now If I want access the turtle file data means I have to use SPARQL query correct right ?

Here is the my big doubt ie which rdf library function I need to use so that I would process and access the sparql query results in my either C/C++ program ( or in simplest way How do i get the sparql query results in my C/C++ program is my worry ) is my big question. Please if have any kind of sample program pls tell me.

please fell free suggest me.
What do mean to access:

1. If you need just to read it, to find if something is equal to something, than you don't need SPARQL. libraptor will be just enough for you (http://librdf.org/raptor/). Using SPARQL in this situation is just unnecessary.

2. If you need to find something, that matches some complex graph, SPARQL will really help you. For this you can use redland rdf libs (libraptor + librdf + librasqal --> http://librdf.org/). Also there is Dataquay (http://breakfastquay.com/dataquay/) and Soprano (http://soprano.sourceforge.net/).

Personally i would recommend you redland libs. Although they are pure c libraries and u'll have to write more lines to do something that in C++ libs, they are very stable and efficient. In the sources of librdf u'll find the examples on how to load turtle/rdf (librdf_parser_parse_into_model) and how to perform queries over rdf model (librdf_model_query_execute).

Are u tied to C/C++? There are a lot of Java solutions.

Could you post a turtle file and a sparql query?
Topic archived. No new replies allowed.