Files
dysync/docs/scripts/检查数据库数据.py
T
yuming b328e82eb2 feat: 视频预览/数据看板/下载配置 三项业务功能
- 新增视频预览:VideoPlayer 组件、VideoController/DyCollectVideoService/Repository、VideoPageRequestDTO 对应后端改动
- 新增数据看板:workplace/statics.vue、RecordTable、相关 store/http/axios 改动
- 新增下载配置:DownloadConfigService、ConfigController、AppSet.vue、AppConfig
- 其他:DyHttpClientService / 同步 Job(Collect, Favorit) / Cookie 表 / CommonService / ServiceExtension 的配套调整
- 仓库卫生:.gitignore 追加 feiniu 过滤;运维脚本归档到 docs/scripts/
2026-04-25 00:22:33 +08:00

82 lines
2.6 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""检查数据库中的视频数据"""
import sqlite3
import os
from pathlib import Path
db_path = "/Users/gaotu/WebstormProjects/dysync.net/db/dy.sqlite"
if not os.path.exists(db_path):
print(f"❌ 数据库文件不存在: {db_path}")
exit(1)
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
print("=" * 60)
print("数据库检查报告")
print("=" * 60)
# 1. 视频总数
cursor.execute("SELECT COUNT(*) FROM dy_collect_video")
total = cursor.fetchone()[0]
print(f"\n1. 视频记录总数: {total}")
# 2. 有保存路径的视频数量
cursor.execute("SELECT COUNT(*) FROM dy_collect_video WHERE videoSavePath IS NOT NULL AND videoSavePath != ''")
with_path = cursor.fetchone()[0]
print(f"2. 有保存路径的视频数量: {with_path}")
# 3. 按类型统计
cursor.execute("SELECT ViedoType, COUNT(*) FROM dy_collect_video GROUP BY ViedoType")
type_stats = cursor.fetchall()
print(f"\n3. 按类型统计:")
for vtype, count in type_stats:
type_name = {"1": "喜欢的", "2": "收藏的", "3": "关注的"}.get(str(vtype), f"未知({vtype})")
print(f" {type_name}: {count}")
# 4. 文件大小统计
cursor.execute("SELECT SUM(fileSize) FROM dy_collect_video WHERE fileSize > 0")
total_size = cursor.fetchone()[0] or 0
print(f"\n4. 总文件大小: {total_size / (1024**3):.2f} GB")
# 5. 最近的视频记录
print(f"\n5. 最近的视频记录(前5条):")
cursor.execute("""
SELECT id, videoTitle, author, videoSavePath, fileSize, syncTime
FROM dy_collect_video
ORDER BY syncTime DESC
LIMIT 5
""")
records = cursor.fetchall()
if records:
for idx, (vid, title, author, path, size, sync_time) in enumerate(records, 1):
title_short = (title[:30] + "...") if title and len(title) > 30 else (title or "无标题")
size_mb = (size / (1024**2)) if size else 0
file_exists = "✅" if path and os.path.exists(path) else "❌"
print(f" {idx}. [{file_exists}] {title_short}")
print(f" 作者: {author}, 大小: {size_mb:.2f} MB")
if path:
print(f" 路径: {path}")
else:
print(" (无记录)")
# 6. 检查文件是否存在
print(f"\n6. 文件存在性检查:")
cursor.execute("SELECT videoSavePath FROM dy_collect_video WHERE videoSavePath IS NOT NULL AND videoSavePath != '' LIMIT 10")
paths = cursor.fetchall()
if paths:
exists_count = 0
for (path,) in paths:
if path and os.path.exists(path):
exists_count += 1
print(f" 检查了 {len(paths)} 个路径,{exists_count} 个文件存在")
else:
print(" (无路径记录)")
conn.close()
print("\n" + "=" * 60)