コード例 #1
0
ファイル: banshee_storage.py プロジェクト: unintended/Cohen
    def sql_execute(self, request, *params, **kw):
        """ Execute a SQL query in the db backend
        """
        t0 = time.time()
        debug_msg = request
        if params:
            debug_msg = u"%s params=%r" % (request, params)
        debug_msg = u''.join(debug_msg.splitlines())
        if debug_msg:
            self.debug('QUERY: %s', debug_msg)

        cursor = self._db.cursor()
        result = []
        cursor.execute(request, params)
        if cursor.description:
            all_rows = cursor.fetchall()
            result = db_row.getdict(all_rows, cursor.description)
        cursor.close()
        delta = time.time() - t0
        self.log("SQL request took %s seconds", delta)
        return result
コード例 #2
0
ファイル: banshee_storage.py プロジェクト: pezam/Cohen
    def sql_execute(self, request, *params, **kw):
        """ Execute a SQL query in the db backend
        """
        t0 = time.time()
        debug_msg = request
        if params:
            debug_msg = u"%s params=%r" % (request, params)
        debug_msg = u''.join(debug_msg.splitlines())
        if debug_msg:
            self.debug('QUERY: %s', debug_msg)

        cursor = self._db.cursor()
        result = []
        cursor.execute(request, params)
        if cursor.description:
            all_rows = cursor.fetchall()
            result = db_row.getdict(all_rows, cursor.description)
        cursor.close()
        delta = time.time() - t0
        self.log("SQL request took %s seconds", delta)
        return result
コード例 #3
0
ファイル: banshee_storage.py プロジェクト: riedel/Cohen3
    def sql_execute(self, request, *params, **kw):
        ''' Execute a SQL query in the db backend
        '''
        t0 = time.time()
        debug_msg = request
        if params:
            debug_msg = f'{request} params={params!r}'
        debug_msg = ''.join(debug_msg.splitlines())
        if debug_msg:
            self.debug(f'QUERY: {debug_msg}')

        cursor = self._db.cursor()
        result = []
        cursor.execute(request, params)
        if cursor.description:
            all_rows = cursor.fetchall()
            result = db_row.getdict(all_rows, cursor.description)
        cursor.close()
        delta = time.time() - t0
        self.log(f'SQL request took {delta} seconds')
        return result