mysql - How to check if a table exists using python? -


i want check whether table exists or not before inserting data. have tried:

def checktables(tablename):     stmt = "show tables %s"%tablename               cursor.execute(stmt)     result = cursor.fetchone()               return result 

but gives me error saying:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'ctg_payload3' @ line 1

maybe not best way.

as opinion, show tables;, search result.

and, cannot execute show tables tablename;, no syntax that.

edit 1

if must in sql, use

 show table status 'table_name'; 

' needed sql.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -