query sparql on sqlite3

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

query sparql on sqlite3

Pakbi
Hi Jiba,
Is it possible to use sqlite3 file for using sparql query without the ontology? If yes, please can you write an example here?
Thanks
Pakbi
Reply | Threaded
Open this post in threaded view
|

Re: query sparql on sqlite3

Jiba
Administrator
Hi,

You cannot perform SPARQL directly on an sqlite3 file. You need to use Python and Owlready for that, because Owlready is in charge of translating SPARQL to SQL.

However, you can :

 * Perform SPARQL queries on the sqlite3 file with Owlready, without loading any ontologies -- even if the quadstore is very big, this can be efficient, depending of the query.

 * Use Owlready to translate predefined SPARQL queries to SQL, and then run the SQL queries directly in sqlite3. You can use the .sql attribute of a prepared SPARQL query to obtain the corresponding SQL code, for example :

>>> default_world.prepare_sparql("SELECT ?c {?c a owl:Class}").sql

'SELECT q1.s FROM objs q1 WHERE q1.p=6 AND q1.o=11'

Jiba