def get_all_users(): # return list of all users in database query = Users.select() result = [] for i in query: result.append((i.id, i.name, i.number, i.email)) return result
def find_user(number=None, email=None): # finding user in database with number or email # function return info about found user, or False nick_exist = True query = '' try: if number: query = Users.select().where( Users.number == number.lower().strip()).get() elif email: query = Users.select().where( Users.email == email.lower().strip()).get() except peewee.DoesNotExist: nick_exist = False print('Данного пользователя нет в системе') return False if nick_exist: return (query.id, query.name, query.gender, query.password, query.number, query.email, query.date_creation)