(self, tbl, ev)
return sql
Return SQL statement(s) for that event.
Return SQL statement(s) for that event.
Return SQL statement ( s ) for that event .
def make_sql(self, tbl, ev):
        """Return SQL statement(s) for that event."""
        
        # parse data
        data = skytools.db_urldecode(ev.data)
            
        # parse tbl info
        if ev.type.find(':') > 0:
            op, keys = ev.type.split(':')
        else:
            op = ev.type
            keys = ev.extra2
        ev.key_list = keys
        key_list = keys.split(',')
        if self.keep_latest and len(key_list) == 0:
            raise Exception('No pkey on table %s' % tbl)

        # generate sql
        if op in ('I', 'U'):
            if self.keep_latest:
                sql = "%s %s" % (self.mk_delete_sql(tbl, key_list, data),
                                 self.mk_insert_sql(tbl, key_list, data))
            else:
                sql = self.mk_insert_sql(tbl, key_list, data)
        elif op == "D":
            if not self.keep_latest:
                raise Exception('Delete op not supported if mode=keep_all')

            sql = self.mk_delete_sql(tbl, key_list, data)
        else:
            raise Exception('Unknown row op: %s' % op)
        return sql
def make_sql ( self , tbl , ev ) : # parse data data = skytools . db_urldecode ( ev . data ) # parse tbl info if ev . type . find ( ':' ) > 0 : op , keys = ev . type . split ( ':' ) else : op = ev . type keys = ev . extra2 ev . key_list = keys key_list = keys . split ( ',' ) if self . keep_latest and len ( key_list ) == 0 : raise Exception ( 'No pkey on table %s' % tbl ) # generate sql if op in ( 'I' , 'U' ) : if self . keep_latest : sql = "%s %s" % ( self . mk_delete_sql ( tbl , key_list , data ) , self . mk_insert_sql ( tbl , key_list , data ) ) else : sql = self . mk_insert_sql ( tbl , key_list , data ) elif op == "D" : if not self . keep_latest : raise Exception ( 'Delete op not supported if mode=keep_all' ) sql = self . mk_delete_sql ( tbl , key_list , data ) else : raise Exception ( 'Unknown row op: %s' % op ) return sql