python更新查询-没有这样的列

时间:2021-06-01 01:51:29

标签: python

enter image description here我的查询几乎不需要帮助。我想更新特定价值的房间、姓名、姓氏,但是我收到错误没有这样的列。任何帮助表示赞赏。

这是我的代码:

def editGuest():
    viewGuests()
    print("Choose room number:")
    roomNumber = input()
    print("You chooose", roomNumber)
    try:
        cur = con.cursor()
        cur.execute("SELECT room,name,surname FROM Guest WHERE room = {}".format(roomNumber))
        rowz= cur.fetchone()
        print("ROOM", "\tNAME", "\tSURNAME")
        print(rowz[0],rowz[1],rowz[2])
        print("What would you like to change?")
        print("1 - Room, 2 - Guest Name, 3 - Guest Surname")
        userInput = input()
        if userInput == "1":
            print("Enter new room number")
            newRoom = input()
            cur.execute("UPDATE Guest SET room = {} WHERE room = {}".format(newRoom, roomNumber))
            con.commit()
        elif userInput == "2":
            print("Enter new name")
            newName = input()
            cur.execute("UPDATE Guest SET name = {} WHERE room = {}".format(newName,roomNumber))
            con.commit()
        elif userInput == "3":
            print("Enter new Surname")
            newSurname = input()
            cur.execute("UPDATE Guest SET surname = {} WHERE room = {}".format(newSurname,roomNumber))
            con.commit()
        else:
            print("Invalid Input")
    except sqlite3.Error as e:
        print(e)

0 个答案:

没有答案