Kamixitong/check_db_structure.py
2025-11-11 23:04:01 +08:00

29 lines
742 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sqlite3
import os
# 连接到正确的数据库文件在instance目录中
db_path = os.path.join('instance', 'kamaxitong.db')
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
# 获取 admin 表的结构信息
cursor.execute('PRAGMA table_info(admin)')
columns = cursor.fetchall()
print('Admin table columns:')
for col in columns:
print(f" {col}")
# 检查是否有 is_deleted 字段
has_is_deleted = any(col[1] == 'is_deleted' for col in columns)
print(f"\nHas is_deleted column: {has_is_deleted}")
# 检查所有表
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = cursor.fetchall()
print(f"\nAll tables:")
for table in tables:
print(f" {table[0]}")
# 关闭连接
conn.close()