Delete data from a db using sqlite3 and Bottle (python)

Asked

Viewed 90 times

0

I am trying to make, using the Bottlepy framework, a CRUD in the Todo format (as in the example shown in the Bottle documentation itself https://bottlepy.org/docs/dev/tutorial_app.html). So far the add item and change item functions are working well. My question is on delete function. The following image summarizes my code: inserir a descrição da imagem aqui

When I click the delete button on my list, I am redirected to the local host link of the selected item (http://localhost:8080/delete2) and I have the following return on the page:

Error: 500 Internal Server Error Sorry, the requested URL 'http://localhost:8080/delete2' caused an error: Internal Server Error

Exception: Valueerror('Parameters are of Unsupported type')

Traceback: Traceback (Most recent call last): File "/home/Jonathan/dev/bottle01/venv/lib/python3.7/site-Packages/Bottle.py", line 862, in _Handle Return route.call(**args) File "/home/Jonathan/dev/bottle01/venv/lib/python3.7/site-Packages/Bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "svr.py", line 50, in delete_item cur.execute ('DELETE FROM todo WHERE id = ?', (nu)) Valueerror: Parameters are of Unsupported type

The problem is: I am unable to delete the selected item. The idea was to make a kind of Alert box to delete the item from the list Todo. Thanks for the help!

  • Good evening Jonathan! Question ? python is a variable, because in the log it is saying that the parameter is not supported, it can be (nu) at the end of the expression, or it can be the ?.

  • Good night, Denis! So the nude is just a variable. As in the image I sent <! -- BOOT DELETE --> <a href="/delete{{Row[0]}}" class="see in bootstrap" onClick="Return confirm('Do you want to delete?')" >Delete</a> check box opens after I hit the delete option located next to the item I want to delete, on an html page. When I hit ok on this check box it returns me to a delete address and the item id. In the other code, the route code, I try to take this id as the naked variable and then at the time of deleting I call the naked value, ie the id generated by my check box.

  • Another observation. I think one of my problems is that the nude is being interpreted as str and I need it to be int.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.