29 lines
706 B
Python
29 lines
706 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
检查数据库中的所有表
|
||
|
|
"""
|
||
|
|
import sqlite3
|
||
|
|
|
||
|
|
def check_tables():
|
||
|
|
"""检查数据库表"""
|
||
|
|
print("=== 检查数据库中的所有表 ===")
|
||
|
|
|
||
|
|
try:
|
||
|
|
# 连接到数据库
|
||
|
|
conn = sqlite3.connect('treasure_box_game.db')
|
||
|
|
cursor = conn.cursor()
|
||
|
|
|
||
|
|
# 查询所有表
|
||
|
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
||
|
|
tables = cursor.fetchall()
|
||
|
|
|
||
|
|
print("数据库表:")
|
||
|
|
for table in tables:
|
||
|
|
print(f"- {table[0]}")
|
||
|
|
|
||
|
|
conn.close()
|
||
|
|
except Exception as e:
|
||
|
|
print(f"数据库连接错误: {e}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
check_tables()
|