def change_pswd():
    userid = input('Enter UserId : ')
    query = 'select * from login;'
    try:
        cursor.execute(query)
        fetch = cursor.fetchall()
        n = len(fetch)
        flag = 0
        for i in range(n):
            if (userid == fetch[i][0]):
                pswd = input('Enter old password : ')
                if (pswd == fetch[i][1]):
                    new_pswd = input('Enter new password : ')
                    query = (((("update login set password = '" + new_pswd) + "' where userid = '") + userid) + "'")
                    try:
                        cursor.execute(query)
                        db.commit()
                        print('Password changed successfully')
                        flag = 1
                    except:
                        db.rollback()
                else:
                    print('Wrong password')
                    flag = 1
        if (flag == 0):
            print('No such user exist!')
    except:
        db.rollback()
        print('Bad')
def change_pswd():
    userid = input('Enter UserId : ')
    query = 'select * from login;'
    try:
        cursor.execute(query)
        fetch = cursor.fetchall()
        n = len(fetch)
        flag = 0
        for i in range(n):
            if (userid == fetch[i][0]):
                pswd = input('Enter old password : ')
                if (pswd == fetch[i][1]):
                    new_pswd = input('Enter new password : ')
                    query = (((("update login set password = '" + new_pswd) + "' where userid = '") + userid) + "'")
                    try:
                        cursor.execute(query)
                        db.commit()
                        print('Password changed successfully')
                        flag = 1
                    except:
                        db.rollback()
                else:
                    print('Wrong password')
                    flag = 1
        if (flag == 0):
            print('No such user exist!')
    except:
        db.rollback()
        print('Bad')