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
I figured it out eventually, I needed to do
cursor.execute('show tables;') for (table_name,) in cursor: print table_name
Log in to post a comment.
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
I figured it out eventually, I needed to do
cursor.execute('show tables;')
for (table_name,) in cursor:
print table_name
Thomas