json decoder error on store.execute_sparql response

18 views
Skip to first unread message

Tim rdf

unread,
May 10, 2012, 12:06:46 AM5/10/12
to sur...@googlegroups.com
SuRF,

I'm getting an odd error when trying to execute a simple SPARQL query
string using SuRF.
Is this a bug, or am I doing something incorrectly?

Thank you for your consideration.

Regards,
Tim Lebo

bash-3.2$ python surf-sparql.py
Load RDF data
Traceback (most recent call last):
File "surf-sparql.py", line 22, in <module>
for person in
session.default_store.execute_sparql(query)['results']['bindings']:
File "/Library/Python/2.7/site-packages/SuRF-1.1.4_r352-py2.7.egg/surf/store.py",
line 200, in execute_sparql
return self.reader.execute_sparql(sparql_query, format = format)
File "/Library/Python/2.7/site-packages/surf.rdflib-1.0.0_r338-py2.7.egg/surf_rdflib/reader.py",
line 87, in execute_sparql
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py",
line 326, in loads
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py",
line 360, in decode
TypeError: expected string or buffer


# ========================= ========================= =========================
from surf import *

store = Store( reader='rdflib',
writer='rdflib',
rdflib_store = 'IOMemory')

session = Session(store)

print 'Load RDF data'
store.load_triples(source='http://www.w3.org/People/Berners-Lee/card.rdf')

query = '''
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?p
WHERE {
?p a foaf:Person
}
'''

for person in session.default_store.execute_sparql(query)['results']['bindings']:
p = person['p']['value']
print p
# ========================= ========================= =========================

cuu...@gmail.com

unread,
May 10, 2012, 9:52:48 AM5/10/12
to sur...@googlegroups.com
Hi Tim,

doesn't look like you're doing anything wrong, --so must be a bug somewhere...
For what it's worth, the same testcase works on my box (also Python
2.7, but Ubuntu 12.04).
Can you try this script with current SVN version of SuRF? If it still
fails the same way, maybe you can do some digging to see what it is
that json decoder fails to decode?

Thanks,
Peteris

2012/5/10 Tim rdf <tim...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "surfrdf" group.
> To post to this group, send email to sur...@googlegroups.com.
> To unsubscribe from this group, send email to surfrdf+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/surfrdf?hl=en.
>
Reply all
Reply to author
Forward
0 new messages