A
A
arndt20002021-10-03 08:18:32
Python
arndt2000, 2021-10-03 08:18:32

There is a syntax error, why?

In line

cursor.execute(f"SELECT id_user FROM users WHERE id_user = {people_id}")

SyntaxError: invalid syntax occurs

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2021-10-03
@SoreMix

f-strings have appeared in Python since version 3.6
But in any case, you should not use f-strings to form SQL queries

cursor.execute("SELECT id_user FROM users WHERE id_user = ?", (people_id,))

A
Azamgl, 2021-10-03
@Azamgl

You can't push an element into a string

G
galaxy, 2021-10-03
@galaxy

The second python, or what?
f-strings only in the third

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question