query single does't work where are the results field empty

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

query single does't work where are the results field empty

Pakbi
query = list(my_world.sparql('''PREFIX onto: <http://test.org/codifa.owl#>
        SELECT ?p { <''' + farm.iri + '''> onto:contiene ?p .}'''))
for item in query:
   PA=item

C:\Users\Pasquale Bonasia\Downloads\OntoPharma>python ./main.py
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Traceback (most recent call last):
  File "./main.py", line 290, in compatibilita
    ?q onto:interazione onto:''' + PA +''' .}'''))
UnboundLocalError: local variable 'PA' referenced before assignment
Reply | Threaded
Open this post in threaded view
|

Re: query single does't work where are the results field empty

Jiba
Administrator
This is not a problem with Owlready. You just forgot to define variable PA.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: query single does't work where are the results field empty

Pakbi
whese I use sparql(query) how I bring the results?
Reply | Threaded
Open this post in threaded view
|

Re: query single does't work where are the results field empty

Pakbi
I have changed:

graph = my_world.as_rdflib_graph()
        query = list(graph.query_owlready('''PREFIX onto: <http://test.org/codifa.owl#>
        SELECT ?p { <''' + farm.iri + '''> onto:contiene ?p .
        ?p onto:contenuto <'''+ farm.iri+'''> .}'''))
        PA = query[0][0]
but I continue to have error on query.