-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcheck_db.py
More file actions
34 lines (28 loc) · 989 Bytes
/
check_db.py
File metadata and controls
34 lines (28 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sqlite3
try:
conn = sqlite3.connect('leaked_keys.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]}")
# 如果有表,查看第一个表的结构
if tables:
first_table = tables[0][0]
cursor.execute(f"PRAGMA table_info({first_table});")
columns = cursor.fetchall()
print(f"\n表 {first_table} 的结构:")
for col in columns:
print(f"- {col[1]} ({col[2]})")
# 查看前几行数据
cursor.execute(f"SELECT * FROM {first_table} LIMIT 5;")
rows = cursor.fetchall()
print(f"\n表 {first_table} 的前5行数据:")
for row in rows:
print(row)
conn.close()
print("\n数据库检查完成")
except Exception as e:
print(f"错误: {e}")