(self, dst_db, ev_list)
Generic dispatcher.
Generic dispatcher.
Generic dispatcher .
def dispatch(self, dst_db, ev_list):
        """Generic dispatcher."""

        # load data
        tables = {}
        for ev in ev_list:
            row = skytools.db_urldecode(ev.data)

            # guess dest table
            if self.part_field:
                if self.part_field == "_EVTIME":
                    partval = str(ev.creation_date)
                else:
                    partval = str(row[self.part_field])
                partval = partval.split(' ')[0]
                date = partval.split('-')
                if self.part_method == 'monthly':
                    date = date[:2]
                suffix = '_'.join(date)
                tbl = "%s_%s" % (self.dest_table, suffix)
            else:
                tbl = self.dest_table

            # map fields
            if self.field_map is None:
                dstrow = row
            else:
                dstrow = {}
                for k, v in self.field_map.items():
                    dstrow[v] = row[k]

            # add row into table
            if not tbl in tables:
                tables[tbl] = [dstrow]
            else:
                tables[tbl].append(dstrow)

        # create tables if needed
        self.check_tables(dst_db, tables)

        # insert into data tables
        curs = dst_db.cursor()
        for tbl, tbl_rows in tables.items():
            skytools.magic_insert(curs, tbl, tbl_rows)
def dispatch ( self , dst_db , ev_list ) : # load data tables = { } for ev in ev_list : row = skytools . db_urldecode ( ev . data ) # guess dest table if self . part_field : if self . part_field == "_EVTIME" : partval = str ( ev . creation_date ) else : partval = str ( row [ self . part_field ] ) partval = partval . split ( ' ' ) [ 0 ] date = partval . split ( '-' ) if self . part_method == 'monthly' : date = date [ : 2 ] suffix = '_' . join ( date ) tbl = "%s_%s" % ( self . dest_table , suffix ) else : tbl = self . dest_table # map fields if self . field_map is None : dstrow = row else : dstrow = { } for k , v in self . field_map . items ( ) : dstrow [ v ] = row [ k ] # add row into table if not tbl in tables : tables [ tbl ] = [ dstrow ] else : tables [ tbl ] . append ( dstrow ) # create tables if needed self . check_tables ( dst_db , tables ) # insert into data tables curs = dst_db . cursor ( ) for tbl , tbl_rows in tables . items ( ) : skytools . magic_insert ( curs , tbl , tbl_rows )