Answer the question
In order to leave comments, you need to log in
How to set variable table name in postgresql python?
Hello!
I'm trying to create a table through code, using a variable as its name, but it doesn't work out.
the code :
db_object.execute(f'SELECT user_id FROM {message.chat.id} WHERE user_id')
result = db_object.fetchone()
print(result)
. syntax error at or near "-"
LINE 1: SELECT user_id FROM -1001532563722 WHERE user_id
replace
and then just adding it when reading, but the code below speaks for itself) db_object.execute('CREATE TABLE IF NOT EXISTS {}'.format('test'))
result = db_object.fetchone()
print(result)
syntax error at end of input
LINE 1: CREATE TABLE IF NOT EXISTS test
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question