def METHOD_NAME(self, clientid, groupids):
    q1 = """delete from GROUPS where clientid = %s"""
    self.c.execute(q1, (clientid,))
    if len(groupids) == 0:
        return
    q2 = """insert into GROUPS (clientid, groupid) values (%s, %s)"""
    for id in groupids:
        self.c.execute(q2, (clientid, id))