Skip to content
Advertisement

python – how to check if table exists?

I’m using this function :

I want to check if the table exists, how can I do it ? I saw some examples using : XXXX.execute() what does it mean?

Here is what I saw :

I tried printing MY_T to see if it returns -1 for example but it just prints "select count (*)...... "

How can I check it? Any help would be very appreciated.

Advertisement

Answer

Use the “TABLES” information schema view. http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

You can apply this view to your code by doing something like the following:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement