kurious
kurious

Reputation: 1044

Error in query while inserting data using RDFlib to GraphDB

I parse a database into an RDFlib graph. I now want to INSERT the triples from this graph into the GraphDB triple store. The code works fine when I execute it on an older version of GraphDB-Lite hosted on Sesame. However, I get an error while executing the same query on the now standalone GraphDB 7.0.0. The graph is partially parsed before the error is raised and the inserted triples do show up in the triple store.

This is part of the code:

graphdb_url = 'http://my.ip.address.here:7200/repositories/Test3/statements'
##Insert into Sesame
        for s,p,o in graph1:
            pprint.pprint ((s,p,o))
            queryStringUpload = 'INSERT DATA {%s %s %s}'  %(s,p,o)
            # queryStringUpload = 'DELETE WHERE {?s ?p ?o .}'
            # print queryStringUpload
            sparql = SPARQLWrapper(graphdb_url)
            sparql.method = 'POST'
            sparql.setQuery(queryStringUpload)
            sparql.query() 

Following is the error:

ARQLWrapper.SPARQLExceptions.QueryBadFormed: QueryBadFormed: a bad request has been sent to the endpoint, probably the sparql query is bad formed. 

Response:
MALFORMED QUERY: Lexical error at line 1, column 93.  Encountered: "/" (47), after : "purl.org"

What is causing the error and how do I resolve it?

Upvotes: 2

Views: 1237

Answers (1)

kurious
kurious

Reputation: 1044

It was a syntax error. I had URIs starting with http:/ instead of http:// in some places.

Upvotes: 5

Related Questions