(self, res, mcur, bres)
Process events in autocommit mode reading results back and trying to make some sense out of them
Process events in autocommit mode reading results back and trying to make some sense out of them
Process events in autocommit mode reading results back and trying to make some sense out of them
def process_batch(self, res, mcur, bres):
        """ Process events in autocommit mode reading results back and trying to make some sense out of them
        """
        try:
            count = 0
            item = bres.copy()
            for i in res:   # for each row in read query result
                item.update(i)
                mcur.execute(self.sql_modify, item)
                self.log.debug(mcur.query)
                if mcur.statusmessage.startswith('SELECT'): # if select was used we can expect some result
                    mres = mcur.fetchall()
                    for r in mres:
                        if 'stats' in r: # if specially handled column 'stats' is present
                            for k, v in skytools.db_urldecode(r['stats'] or '').items():
                                self.stat_increase(k, int(v))
                        self.log.debug(r)
                else:
                    self.stat_increase('processed', mcur.rowcount)
                    self.log.debug(mcur.statusmessage)
                if 'cnt' in item:
                    count += item['cnt']
                    self.stat_increase("count", item['cnt'])
                else:
                    count += 1
                    self.stat_increase("count")
                if self.last_sigint:
                    break
            return count, item
        except: # process has crashed, run sql_crash and re-raise the exception
            if self.sql_crash:
                dbc = self.get_database("dbcrash", autocommit=1)
                ccur = dbc.cursor()
                ccur.execute(self.sql_crash, item)
            raise
def process_batch ( self , res , mcur , bres ) : try : count = 0 item = bres . copy ( ) for i in res : # for each row in read query result item . update ( i ) mcur . execute ( self . sql_modify , item ) self . log . debug ( mcur . query ) if mcur . statusmessage . startswith ( 'SELECT' ) : # if select was used we can expect some result mres = mcur . fetchall ( ) for r in mres : if 'stats' in r : # if specially handled column 'stats' is present for k , v in skytools . db_urldecode ( r [ 'stats' ] or '' ) . items ( ) : self . stat_increase ( k , int ( v ) ) self . log . debug ( r ) else : self . stat_increase ( 'processed' , mcur . rowcount ) self . log . debug ( mcur . statusmessage ) if 'cnt' in item : count += item [ 'cnt' ] self . stat_increase ( "count" , item [ 'cnt' ] ) else : count += 1 self . stat_increase ( "count" ) if self . last_sigint : break return count , item except : # process has crashed, run sql_crash and re-raise the exception if self . sql_crash : dbc = self . get_database ( "dbcrash" , autocommit = 1 ) ccur = dbc . cursor ( ) ccur . execute ( self . sql_crash , item ) raise