'Commands out of sync; you can't run this command now. How do i change this?

import mysql.connector
db = mysql.connector.connect(user='root', password='*****',host='localhost',database='hotel')
cursor=db.cursor()
try:
    sql="create table Date(checkin char(20),checkout char(20),guest int,room int,name varchar(100),address varchar(100));"
    cursor.execute(sql)
    db.commit()
except:
    pass
def booking():
    cin=str(input('Enter check-in date(yyyy-mm-dd): '))
    cout=str(input('Enter check-out date(yyyy-mm-dd): '))
    guest=int(input('Enter number of guests: '))
    room=int(input("\t1. Standard Room\n\t2. Deluxe Room\n\t3. Executive Room\n\t4. Suite\n"))
    name=input('Enter your name: ')
    ad=input('Eneter your address: ')
    l=[cin,cout,guest,room,name,ad]
    cust=(l)
    sql="insert into Date values(%s,%s,%s,%s,%s,%s);"
    cursor.execute(sql,cust)
    db.commit()
    sqlb="select room, case when count(room)<5 then 'available' else 'not' end as 'abc' from Date;"
    cursor.execute(sqlb)
    db.commit()
booking()

This is giving me an error "Commands out of sync; you can't run this command now" and don't know how to correct it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source