Beispiel #1
0
 def queryd(self, query, initBindings={}):
     # initBindings keys can be Variable, but they should not
     # include the questionmark or else they'll get silently
     # ignored
     interpolated = interpolateSparql(query, initBindings)
     # print interpolated
     query = self.sparqlHeader + interpolated
     xml = self.root.get(
         "/" + self.repoName, query=query, queryLn="SPARQL", headers={"Accept": "application/sparql-results+xml"}
     ).body_string()
     return parseSparqlResults(xml.encode("utf-8"))
Beispiel #2
0
 def queryd(self, query, initBindings={}):
     # initBindings keys can be Variable, but they should not
     # include the questionmark or else they'll get silently
     # ignored
     interpolated = interpolateSparql(query, initBindings)
     #print interpolated
     query = self.sparqlHeader + interpolated
     xml = self.root.get('/' + self.repoName,
                         query=query, queryLn='SPARQL',
                         headers={'Accept' :
                                  'application/sparql-results+xml'}
                         ).body_string()
     return parseSparqlResults(xml.encode('utf-8'))
Beispiel #3
0
        def checkType(result):
            if self.resultFormat == 'json':
                # virtuoso can do an aggregate query and give just the
                # count, but I haven't implemented that yet.
                return jsonRowCount(result)

            tree = ElementTree.fromstring(result)
            # if it's pre-counted, return that
            try:
                return parseCountTree(tree)
            except ValueError:
                # server didn't get our hint, so it returned all the rows
                rows = parseSparqlResults(tree)
                return len(rows)
Beispiel #4
0
 def checkType(result):
     if self.resultFormat == 'json':
         # virtuoso can do an aggregate query and give just the
         # count, but I haven't implemented that yet.
         return jsonRowCount(result)
     
     tree = ElementTree.fromstring(result)
     # if it's pre-counted, return that
     try:
         return parseCountTree(tree)
     except ValueError:
         # server didn't get our hint, so it returned all the rows
         rows = parseSparqlResults(tree)
         return len(rows)