I use Flask, WTForms and OurSQL MySQL library for my application. I get message data from a variable request.form. I put this in a WTForms form object. I call validate()in this form and then insert the form data into the MySQL database using OurSQL.
Without any additional processing, am I sure of SQL injection? Does the WTForms method help validateescaping? If not, what should I do to avoid data? An example of what I am doing is as follows:
form = MyWTFFormsForm(request.form)
if form.validate():
cursor.execute("INSERT INTO mytable VALUES (?, ?, ?, ?, ?);",
(form.field1.data, form.field2.data, form.field3.data,
form.field4.data,
form.field5.data))
source
share