import MySQLdb
connection = MySQLdb.connect(host='localhost', user='myself', passwd='mysecret'
    )
cursor = connection.cursor()
cursor.execute('USE mydatabase')
cursor.execute('SHOW TABLES')
How to retrieve table names in a mysql database with Python and MySQLdb?