I wanted to delete the data that had the checkbox checked in the form below.
index.html
<form action="{{ url_for('delete_data') }}" method="post" enctype="multipart/form-data">
<ul>
{% for entry in result %}
<li>
<input type="checkbox" name="action" value="{{ entry[0] }}">{{ entry[1] }}:{{ entry[2] }}
</li>
{% endfor %}
</ul>
<input type="submit" value="Delete">
</form>
index.py
if request.method == 'POST':
data_ids= request.form['action']
I wanted to pass the variable that I received like this.
index.py
c.execute('''DELETE FROM message WHERE data_id=data_ids''')
This makes me angry many times.
It seems that I should have written this. If you pass it as a variable, it will be like this ...
index.py
query = "DELETE FROM message WHERE data_id=?"
c.execute(query,(data_ids,))
Recommended Posts