S
S
Sanzhar Bazarbek2022-04-20 20:09:48
MySQL
Sanzhar Bazarbek, 2022-04-20 20:09:48

How can I change the name of a table in a database query?

I have every query to the database changes the name of the table
Because of its change, an error occurs with incorrect syntax

cursor.execute('''
        CREATE TABLE IF NOT EXISTS %s (
            id              INT AUTO_INCREMENT,
            PRIMARY KEY     (id)
        )
''', (tableName))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2022-04-20
@Rezvor

In this form, no way. Substitution works only in crud requests and only for value substitution.
The only option is to write a function that will clean up the data and substitute only the values ​​returned from such a function through f-strings .
But even so, if you think that you really need it - think again, are there any other ways to solve it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question