0

My function definition looks something like this:

def chk_table(table_name):
    .......
    .......
    conn.execute('SELECT * FROM table_name ;')
    print("The response for query : SELECT * FROM table_name; === ",repr(conn.response) )
    return

I get the below error:

Exscript.protocols.exception.InvalidCommandException: Device said:
SELECT * FROM table_name;
Error: no such table: table_name

Can anybody help me to resolve this issue?

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
samrac
  • 1
  • 2
  • You are hard-coding the "table_name". Duplicate with https://stackoverflow.com/questions/26324996/replace-table-name-with-variable-using-python-and-mysql-connector – Juho Rutila Nov 29 '18 at 11:36
  • Also related https://stackoverflow.com/questions/11312737/can-i-parameterize-the-table-name-in-a-prepared-statement (php question, but more generic answer). – 9769953 Nov 29 '18 at 11:57
  • Possible duplicate of [Replace table name with variable. Using python and mysql connector](https://stackoverflow.com/questions/26324996/replace-table-name-with-variable-using-python-and-mysql-connector) – 9769953 Nov 29 '18 at 12:42

0 Answers0