0

I'm trying to update two rows in SQLite with Python:

Puntero.execute(
"UPDATE '{T}' set '{F}' = '{C}','{V}' = '{U}' where ID='{I}'"
.format(T = Tabl, F = fecha, V = Vendidos, U = id, C= Cantidad, I=id))

Thanks for helping!

1
  • "... where ID='{I}' OR ID='{I_other}'".format(... I=id, I_other=id_other) Commented May 18, 2017 at 7:08

1 Answer 1

1

First, don't do it that way. You are setting yourself up for SQL injections. Use placeholders instead.

What you want is:

Puntero.execute(
   "UPDATE Tabl set fecha = :C, Vendidos = :U where ID=in(:I1, :I2)", 
      {"U": id, "C":Cantidad, "I1":id, "I2":otherid}
)
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Chris, now It is necessary to take into account that tablet, is a variable, that takes many values.
IN () can take any number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.