コード例 #1
0
ファイル: sesame.py プロジェクト: drewp/sparqlhttp
 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"))
コード例 #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'))
コード例 #3
0
ファイル: remotegraph.py プロジェクト: drewp/sparqlhttp
        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)
コード例 #4
0
ファイル: remotegraph.py プロジェクト: drewp/sparqlhttp
 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)