Beispiel #1
0
def get_user_from_uid(uid):
    fields = [
        'id', 'username', 'phone', 'role', 'cn_name', 'position', 'password',
        'email'
    ]
    sql = '''SELECT %s FROM users WHERE id = '%s';''' % (','.join(fields), uid)
    print sql
    values = select_result(sql)
    return dict(zip(fields, values))
Beispiel #2
0
def get_role_from_username(username):
    sql = '''SELECT role FROM users WHERE username = '******';''' % username
    return select_result(sql)
Beispiel #3
0
def get_passwd_from_username(username):
    sql = '''SELECT password FROM users WHERE username = '******';''' % username
    return select_result(sql)
Beispiel #4
0
def get_role_from_username(username):
    sql = '''SELECT role, cn_name FROM users WHERE username = '******';''' % username
    app.logger.debug(select_result(sql))
    return select_result(sql)
Beispiel #5
0
def get_uid_from_username(username):
    sql = '''SELECT id FROM users WHERE username = '******';''' % username
    uid = select_result(sql)
    if uid:
        return uid[0], True
    return None, False
Beispiel #6
0
def validate_uid_exists(uid):
    sql = '''SELECT * FROM users WHERE id = '%s';''' % uid
    num = select_result(sql)
    if not num:
        return None, False
    return 'username:%s already exists.' % uid, True
Beispiel #7
0
def validate_user_exists(username):
    sql = '''SELECT * FROM users WHERE username = '******';''' % username
    num = select_result(sql)
    if not num:
        return None, False
    return 'username:%s already exists.' % username, True
Beispiel #8
0
def get_users_count():
    sql = '''SELECT count(*) FROM users; '''
    return select_result(sql)
Beispiel #9
0
def get_assets_count():
    sql = '''SELECT count(*) FROM assets; '''
    return select_result(sql)