L
L
leroy-bit2021-07-24 18:57:33
Python
leroy-bit, 2021-07-24 18:57:33

What is wrong with sql query?

cur.execute('SELECT ? FROM ?', [column_name, table_name,])
for element in cur.fetchall():
result.append(element[0])
return result


When executing this code, an error occurs:
cur.execute('SELECT ? FROM ?', [column_name, table_name,]
sqlite3.OperationalError: near"?": syntax error

I don't understand what the problem is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-07-24
@leroy-bit

You cannot substitute column and table names.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question