i'm trying to execute following script in python3, which suppose to connect to database, get list of tables, and then return describe statement ,but whole time python seems to change `` for '' and returns me following error:
File "apka_baz.py", line 17, in <module>
for result in cursor.execute(describe, smthn):
File "/usr/local/lib/python3.7/site-packages/mysql/connector/cursor.py", line 559, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "/usr/local/lib/python3.7/site-packages/mysql/connector/connection.py", line 494, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
File "/usr/local/lib/python3.7/site-packages/mysql/connector/connection.py", line 396, in _handle_result
raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test_table'' at line 1
Code:
# Open database connection
db = conn.connect(user="sb",password="smtn",host="172.blabla",database="blabla")
# prepare a cursor object using cursor() method
cursor = db.cursor()
describe = ("show create table %s")
cursor.execute("SHOW TABLES")
for row in cursor.fetchall():
smthn = (row[0],)
print(describe % smthn)
for result in cursor.execute(describe, smthn):
print(result)
for rows in cursor.fetchall():
print(rows)
It's probably fault of changes described earlier, but still i can't get solution
%s