import re

counts = {}
current_table = None

with open('xygameco_xygaming.sql', 'r', encoding='utf-8', errors='ignore') as f:
    for line in f:
        line_s = line.strip()
        if line_s.startswith('INSERT INTO'):
            m = re.match(r'INSERT INTO [`"]?([a-zA-Z0-9_]+)[`"]?', line_s)
            if m:
                current_table = m.group(1)
                if current_table not in counts:
                    counts[current_table] = 0
        elif current_table and line_s.startswith('('):
            # Each line starting with '(' is a record tuple
            counts[current_table] += 1
        elif line_s.endswith(';'):
            current_table = None

print("=== MARIADB DATABASE CONTENTS ===")
for tbl, count in sorted(counts.items(), key=lambda x: x[1], reverse=True):
    print(f"{tbl}: {count:,} records")
