Menu

Listing tables

Help
2009-06-24
2012-09-19
  • Thomas Robitaille

    Hi,

    I'm trying to get a list of all the tables in a database. I tried using 'show tables', but the result is just a long integer:

    In [4]: cursor.execute('show tables')
    Out[4]: 7L

    Is there an easy way to get a full list of the tables in a given database?

    Thanks,

    Thomas

     
    • Thomas Robitaille

      I figured it out eventually, I needed to do

      cursor.execute('show tables;')
      for (table_name,) in cursor:
      print table_name

      Thomas

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.