def getCounts(conn, showEmpty = True):
    """Get counts of all InterMine database tables.

    Returns a dictionary of <table-name>:<count>

    conn - open database connection
    showEmpty - if true then 0 counts are also shown"""

    with conn.cursor() as cur:
        cur.execute("select table_name from information_schema.tables where table_schema='public' order by table_schema, table_name;")
        tables = cur.fetchall()
        results = {}

        for table in tables:
            table = table[0]

            cur.execute("select count(*) from %s" % table)
            count = cur.fetchone()[0]

            if showEmpty or count > 0:
                results[table] = count
                # prettySummaryTable.add_row([table, count])
                # print "%s: %s" % (table, count)

        return results