[PYTHON] Where I stumbled on SQLite3

Where I stumbled

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.

Conclusion

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

Where I stumbled on SQLite3
I stumbled on the Hatena Keyword API
I stumbled upon installing sentencepiece on ubuntu
What I did when I stumbled on a Django tutorial
I installed tensorRT on Ubuntu 18.04
Notes on python's sqlite3 module
I installed ROS on Ubuntu 18.04
Points that stumbled on GORM
I stumbled upon trying Pylearn 2
I ran python on windows
I stumbled on TensorFlow (What is Out of GPU Memory)
I tried MLflow on Databricks
What I stumbled upon when using CodeIgniter on a Linux server
I tried AdaNet on table data
What I stumbled upon using Airflow
I get an ImportError on appengine_config.py
Where I was worried about heroku
[Linux] I installed CentOS on VirtualBox
I tried Cython on Ubuntu on VirtualBox
I couldn't input Japanese on Ubuntu 20.04
I installed Linux on my Mac
A memorandum because I stumbled on trying to use MeCab in Python