Files
ylt_diy/check_history.py

51 lines
1.5 KiB
Python
Raw Normal View History

"""
检查历史记录中的文件路径
"""
from lib.db import execute_query
print("=" * 60)
print("检查历史记录中的文件路径")
print("=" * 60)
try:
result = execute_query("""
SELECT
id,
report_date,
split_value,
total_orders,
status,
file_path,
create_time
FROM t_daily_report_history
ORDER BY create_time DESC
LIMIT 5
""")
if not result:
print("⚠ 历史记录表为空")
else:
print(f"\n找到 {len(result)} 条记录:\n")
for item in result:
print(f"ID: {item['id']}")
print(f" 日期: {item['report_date']}")
print(f" 拆分值: {item['split_value']}")
print(f" 订单数: {item['total_orders']}")
print(f" 状态: {'成功' if item['status'] == 1 else '失败'}")
print(f" 文件路径: '{item['file_path']}'")
print(f" 文件路径是否为空: {not item['file_path']}")
print(f" 创建时间: {item['create_time']}")
print("-" * 60)
# 检查文件是否存在
if item['file_path']:
import os
full_path = os.path.join('public', item['file_path'])
print(f" 完整路径: {full_path}")
print(f" 文件是否存在: {os.path.exists(full_path)}")
print()
except Exception as e:
print(f"✗ 查询失败: {e}")
import traceback
traceback.print_exc()