G
G
Galina2021-08-18 01:20:16
Python
Galina, 2021-08-18 01:20:16

How to add quotes to SQL in Python if curly braces are used?

Value abc =1503915010_3
Cur.execute
(f"UPDATE telephone SET ABCOUNT = {abc}, delete_abcount = 0 WHERE TEL = {tel} AND ABCOUNT IS NULL")
produces
an sqlite3.OperationalError: unrecognized token: "1503915010_3"
I I understand that you need to put quotes, but how to write it correctly in case of using curly braces?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-08-18
@OdesGal

So. Make. Not. Necessary.

cur.execute(f"UPDATE telephone SET ABCOUNT = :abc, delete_abcount = 0 WHERE TEL = :tel AND ABCOUNT IS NULL", {"abc": abc, "tel": tel})

everything will be added if the types are correct

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question