"""Dump legacy SQLite schema helpers."""
import sqlite3
import sys
from pathlib import Path


def main():
    path = Path(sys.argv[1] if len(sys.argv) > 1 else r'D:\db.sqlite3')
    conn = sqlite3.connect(path)
    conn.row_factory = sqlite3.Row
    cur = conn.cursor()
    for table in sys.argv[2:] if len(sys.argv) > 2 else [
        'accounts_user', 'store_item', 'business_businessaccount',
        'store_jobapplicant', 'profile_store_subscription',
    ]:
        print(f'\n--- {table} ---')
        cur.execute(f'PRAGMA table_info([{table}])')
        for col in cur.fetchall():
            print(f"  {col['name']} ({col['type']})")
        cur.execute(f'SELECT * FROM [{table}] LIMIT 1')
        row = cur.fetchone()
        if row:
            print('  sample:', dict(row))
    conn.close()


if __name__ == '__main__':
    main()
