def execute(self, activity, graph=None, query=None):
        if graph is not None:
            headers = {'User-agent':   'Arelle/1.0',
                       'Accept':       'application/sparql-results+json',
                       'Content-Type': "text/turtle; charset='UTF-8'"}
            data = graph.serialize(format='pretty-xml' if self.isRdfXmlFile else 'turtle', 
                                   encoding='utf=8')
        elif query is not None:
            headers = {'User-agent':   'Arelle/1.0',
                       'Accept':       'application/sparql-results+json'}
            data = ("query=" + query).encode('utf-8')
        else:
            return None
        # turtle may be mixture of line strings and strings with \n-separated lines
        if TRACERDFFILE:
            with io.open(TRACERDFFILE, "ab") as fh:
                fh.write(b"\n\n>>> sent: \n")
                fh.write(data)
        if (self.isRdfTurtleFile or self.isRdfXmlFile) and data is not None:
            with io.open(self.turtleFile, "ab") as fh:
                fh.write(data)
            return None
        if graph is not None or query is not None:
            url = self.url + "/sparql"
        request = urllib.request.Request(url,
                                         data=data,
                                         headers=headers)
        try:
            with self.conn.open(request, timeout=self.timeout) as fp:
                results = fp.read().decode('utf-8')
            try:
                results = json.loads(results)
            except __HOLE__:
                pass # leave results as string
        except HTTPError as err:
            results = err.fp.read().decode('utf-8')
        if TRACERDFFILE:
            with io.open(TRACERDFFILE, "a", encoding='utf-8') as fh:
                fh.write("\n\n>>> received: \n{0}".format(str(results)))
        if isinstance(results, str) and query is not None:
            parser = etree.HTMLParser()
            htmlDoc = etree.parse(io.StringIO(results), parser)
            body = htmlDoc.find("//body")
            if body is not None:
                error = "".join(text for text in body.itertext())
            else:
                error = results
            raise XRDBException("xrdfDB:DatabaseError",
                                _("%(activity)s not successful: %(error)s"),
                                activity=activity, error=error) 
        return results
dataset/ETHPy150Open Arelle/Arelle/arelle/plugin/xbrlDB/XbrlSemanticRdfDB.py/XbrlSemanticRdfDatabaseConnection.execute