#!/usr/bin/env python3
"""
查询ads表中对应视频文件的记录，确认adname格式
"""
import sqlite3

# 数据库路径
db_path = "\\\\ll\\D\\xtrssvjj\\dbbak\\dpd.db"

try:
    # 连接数据库
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    
    # 查询ads表中包含"井底之蛙"或"阿尔忒弥斯"的记录
    print("查询ads表记录:")
    cursor.execute("SELECT * FROM ads WHERE name LIKE ? OR name LIKE ? LIMIT 5", ('%井底之蛙%', '%阿尔忒弥斯%'))
    results = cursor.fetchall()
    
    if results:
        print(f"找到 {len(results)} 条记录:")
        # 查看ads表结构
        cursor.execute("PRAGMA table_info(ads)")
        columns = cursor.fetchall()
        headers = [col[1] for col in columns]
        print("  " + " | ".join(headers))
        print("  " + "-" * 120)
        
        for row in results:
            row_str = "  " + " | ".join(str(item) for item in row)
            print(row_str)
    else:
        print("  无匹配记录")
    
    # 关闭连接
    conn.close()
    
except Exception as e:
    print(f"错误: {e}")
