Kamixitong/check_db_structure.py

29 lines
742 B
Python
Raw Normal View History

2025-11-11 23:04:01 +08:00
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()