第一次提交。
其中爬取是tophub_scraper.py 数据入库是 tophub_add_data_to_db.py 查看当前数据内容是 db_viewer.py
This commit is contained in:
25
check_db_structure.py
Normal file
25
check_db_structure.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
import sqlite3
|
||||
|
||||
# 连接到数据库
|
||||
conn = sqlite3.connect('tophub_data.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]}")
|
||||
|
||||
# 获取每个表的结构
|
||||
for table in tables:
|
||||
table_name = table[0]
|
||||
print(f"\n表 '{table_name}' 的结构:")
|
||||
cursor.execute(f"PRAGMA table_info({table_name});")
|
||||
columns = cursor.fetchall()
|
||||
for column in columns:
|
||||
print(f" {column[1]} ({column[2]})")
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user