in Education by
I basically have 2 python scripts one is for frontend other is for backend. On Frontend I have this: def delete_command(): back.delete(selected_tuple[0]) So basically click on a entry in a listbox then on backend script it has the database call (sqllite3) def delete(id): BASE_DIR = os.path.dirname(os.path.abspath(__file__)) db_path = os.path.join(BASE_DIR, "AVDatabase.db") conn=sqlite3.connect(db_path) cur=conn.cursor() cur.execute('DELETE * FROM "Books" where BookId=?',(BookId,)) conn.commit() conn.close() But i keep getting an error: cur.execute('DELETE * FROM "Books" where BookId=?',(BookId,)) NameError: name 'BookId' is not defined The database already exists so its not dynamically created not sure why it considers the BookID column as not defined, BookID is a primary key integer on the main Books Table. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You are not defining BookId. The delete() method requires a parameter named id and you are not using it anywhere in the definition. replace BookId with id here: cur.execute('DELETE * FROM "Books" where BookId=?',(BookId,)) to cur.execute('DELETE * FROM "Books" where BookId=?',(id,)) def delete(id): BASE_DIR = os.path.dirname(os.path.abspath(__file__)) db_path = os.path.join(BASE_DIR, "AVDatabase.db") conn=sqlite3.connect(db_path) cur=conn.cursor() cur.execute('DELETE * FROM "Books" where BookId=?',(id,)) conn.commit() conn.close()

Related questions

0 votes
    I need to find a way to clear the Listbox for the refresh function which I am making. The function should ... clearing the Listbox) Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    I want to use python to connect to a MySQL database, how can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    So I tried reading the file and I confirmed it worked and then tried adding the contents to a listbox ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I want to delete some certain characters that used wrongly in a string. "........I.wanna.delete. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have deleted a folder containing a running Vagrant box before realizing it was still running. How can I delete ... the Virtualbox VM. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Write the command used for deleting a selected file from the SVN Repo?...
asked Feb 21, 2021 in Technology by JackTerrance
0 votes
    How can I remove this file from the repo without deleting my local copy of the file?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I've got an output from an API call as a list: out = client.phrase_this(phrase='ciao', database= ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I've got an output from an API call as a list: out = client.phrase_this(phrase='ciao', database= ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have a given list of string and a list of characters and I want to check the string with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I'm currently developing my first python program, a booking system using tkinter. I have a customer account ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I want to download videos from a website. Here is my code. Every time when i run this code, it ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'm using the following method to send mail from Python using SMTP. Is it the right method to use ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
...