0

I am using SqlAlchemy to connect to a MySQL database instance, and trying to look at the tables by doing the following:

   engine = create_engine('mysql+pymysql://root:@localhost:3306', echo=True)
   engine.execute("USE mydb;")
   q = engine.execute("show tables;")
   our_tables = q.fetchall()
   print(our_tables)

When I try and print the tables this way it shows them as blank. However when I inspect the database, everything looks good for those tables.

What can I do to view the tables correctly?

William Ross
  • 3,568
  • 7
  • 42
  • 73
  • 1
    Try modifying the connection string as described in http://docs.sqlalchemy.org/en/latest/core/engines.html#mysql to include the db as well. – mad_ Aug 02 '18 at 16:34
  • Possible duplicate of [SQLAlchemy - Getting a list of tables](https://stackoverflow.com/questions/6473925/sqlalchemy-getting-a-list-of-tables) – Danila Ganchar Aug 09 '18 at 13:43

0 Answers0