Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello This is my code for a school project
I've created two python files for this.
One is main.py and other one is book.py

While running my code it's showing me this error. It would be very helpful if you can solve my problem and give an effective solution.


What I have tried:

Here's my code for book.py of function add_stock

Python
def add_stock() :            
        print('Add Stock'.center(89 , '='))
        bno = unique_book_no()
        if bno :
            print("Book Number : " , bno)
        else : bno = int(input("Enter book number : "))
        bname = input("Enter the Book\'s Name : ")
        auth = input("Enter the Author of the Book : ")
        publ = input("Enter the Publisher of the Book : ")
        cost = eval(input("Enter the Cost per Book : "))
        stock = int(input("Enter the Quantity purchased : "))
        __cur.execute("insert into stock values ({} , '{}' , '{}' , '{}' , {} , {} , {} , '{}')".format(bno , bname , auth , publ , cost , stock , 0, __dt.date.today()))
        print("Inserted Successfully !!!")



And this one of book.py for function unique_book_no


Python
def unique_book_no () :
        __cur.execute("select max(Book_No) from stock")
        data = __cur.fetchall(buffered=True)
        if bool(data[0][0]) :
            L1 = [x for x in range((data[0][0] + 1) , (data[0][0] + 10000))]
            shuffle(L1)
            return L1.pop(0)
        else : return False


I'm getting this error


Python
Traceback (most recent call last):
      File "D:\CBSE 12\cs projects\Main.py", line 35, in <module>
        Book.add_stock()
      File "D:\CBSE 12\cs projects\Book.py", line 38, in add_stock
        bno = unique_book_no()
      File "D:\CBSE 12\cs projects\Book.py", line 90, in unique_book_no
        __cur.execute("select max(Book_No) from stock")
      File "C:\Python 37\lib\site-packages\mysql\connector\cursor.py", line 538, in execute
        self._connection.handle_unread_result()
      File "C:\Python 37\lib\site-packages\mysql\connector\connection.py", line 1455, in handle_unread_result
        raise errors.InternalError("Unread result found")
    mysql.connector.errors.InternalError: Unread result found
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900