Pour être un peu plus complet :
import MySQLdb
connection = MySQLdb.connect(
host = 'localhost',
user = 'myself',
passwd = 'mysecret') # create the connection
cursor = connection.cursor() # get the cursor
cursor.execute("USE mydatabase") # select the database
cursor.execute("SHOW TABLES") # execute 'SHOW TABLES' (but data is not returned)
maintenant il y a deux options :
tables = cursor.fetchall() # return data from last query
ou itérer sur le curseur :
for (table_name,) in cursor:
print(table_name)