コード例 #1
0
def getDosenProfile(NIP):
    queryDosen = "select id, NIP ,nama, jenis_kelamin, email from dosen where NIP = '{0}'".format(
        NIP)
    cusrsor = ExecuteSql(queryDosen)
    result = cusrsor.fetchone()
    dosen = Dosen()
    dosen.id = result[0]
    dosen.NIP = result[1]
    dosen.nama = result[2]
    dosen.jenis_kelamin = result[3]
    dosen.email = result[4]
    return dosen
コード例 #2
0
def login(username, password, loginAs):

    query = ''
    if loginAs == 'mahasiswa':
        query = "select count(*) from {0} where {1} = '{2}' AND password = '******' ".format(
            'mahasiswa', 'id_mahasiswa', username, password)
    elif loginAs == 'dosen':
        query = "select count(*) from {0} where {1} = '{2}' AND password = '******' ".format(
            'dosen', 'NIP', username, password)
    else:
        query = "select count(*) from {0} where {1} = '{2}' AND password = '******' ".format(
            'admin', 'NIP', username, password)
    try:
        cursor = ExecuteSql(query)
        row = cursor.fetchone()
    except:
        pass
    if row[0] <= 0:
        return False
    session['username'] = username
    session['login'] = loginAs
    return True