Menu

show tables?

Help
bilbod
2006-05-06
2013-04-11
  • bilbod

    bilbod - 2006-05-06

    Is this the easiest way to get a list of database tables?

    db=pdo.connect("Module=MySQLdb;User=%s;Passwd=%s;DB=%s" % (un,pw,dbs))
    if db.active:
      showTables='show tables'
      result=db.openRS(showTables)
      tables=[]
      while result.next():
        for r in result.fields:
          tables.append(result.fields[r].value)
      print tables

     
    • Nate Reid

      Nate Reid - 2006-05-08

      I think that 'openRS' is deprecated, and 'open' is the correct method.  Other than than, it looks like there isn't a simpler way to query the database to list tables/databases/or other meta information.

       

Log in to post a comment.