import sqlite3
import pandas as pd
import os

db_path = 'law_risk.db'
excel_path = '主题-事项绑定.xlsx'

print("--- Database Schema ---")
if os.path.exists(db_path):
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
    tables = cursor.fetchall()
    for table_name in tables:
        print(f"Table: {table_name[0]}")
        cursor.execute(f"PRAGMA table_info({table_name[0]})")
        columns = cursor.fetchall()
        for col in columns:
            print(f"  {col[1]} ({col[2]})")
    conn.close()
else:
    print(f"Database file not found: {db_path}")

print("\n--- Excel File Preview ---")
if os.path.exists(excel_path):
    try:
        df = pd.read_excel(excel_path)
        print(df.head())
        print("\nColumns:", df.columns.tolist())
    except Exception as e:
        print(f"Error reading Excel: {e}")
else:
    print(f"Excel file not found: {excel_path}")
