Error message

My code for import.py Whenever I run my code, I get a strange error message because of my code. It is because of my SQL code, but I followed all of the instructions, and even tried some other SQL code, which worked successfully. Please help me understand what it means.

  • Did you forget to use a parametrized query to prevent sql injection, as discussed in the lecture starting around 1:43:00? You'll find examples in the source code – DinoCoderSaurus May 9 '20 at 22:59

I have figured it out, thank you DinoCoderSauraus. It was because to use a variable in db.execute, I needed to use the f, for format. I needed to write,

db.execute(f"INSERT INTO students (first, middle, last, house, birth) VALUES ('{name[0]}', '{middle}', '{name[len(name)-1]}', '{x[1]}', {x[2]});")


  • That solves the problem but it's not the optimal solution. Your app is wide open to sql injection. You should use parameterized queries. Make it a habit. – DinoCoderSaurus May 10 '20 at 3:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .