def get_by_id(cur, id): result = mysql_util.query(cur, 'SELECT * FROM t_user WHERE id = {_id}'.format(_id=id)) if len(result) > 0: u = result[0] return User(u[1], u[2], u[0]) else: return None
def get_all(cur): result = mysql_util.query(cur, 'SELECT * FROM t_user') u_list = [] for u in result: usr = User(u[1], u[2], u[0]) u_list.append(usr) return u_list