from settings import *

dbconn = connect_db()
cursor = dbconn.cursor()

cursor.execute("show tables")

tablerows = {}

while 1:
	row = cursor.fetchone()
	if row == None: break
	tablename = row[0]
	
	c2 = dbconn.cursor()
	c2.execute("select count(*) from "+tablename)
	count = int(c2.fetchone()[0])
	c2.close()

	# print tablename, (50 - len(tablename)) * " ", count
	tablerows[tablename] = count

def sort(x, y):
	return tablerows[x] - tablerows[y]

tables = tablerows.keys()
tables.sort(sort)

for t in tables:
	print t, (50 - len(t)) * " ", tablerows[t]
	
