30 lines
751 B
Python
30 lines
751 B
Python
![]() |
from database import DatabaseManager
|
||
|
import os
|
||
|
|
||
|
# 使用backend/data目录下的数据库路径
|
||
|
db_path = os.path.join(os.path.dirname(__file__), 'data', 'body_balance.db')
|
||
|
db = DatabaseManager(db_path)
|
||
|
db.init_database()
|
||
|
conn = db.get_connection()
|
||
|
cursor = conn.cursor()
|
||
|
|
||
|
# 检查患者总数
|
||
|
cursor.execute('SELECT COUNT(*) FROM patients')
|
||
|
count = cursor.fetchone()[0]
|
||
|
print(f'患者总数: {count}')
|
||
|
|
||
|
# 查看前5条患者数据
|
||
|
cursor.execute('SELECT * FROM patients LIMIT 5')
|
||
|
rows = cursor.fetchall()
|
||
|
print('前5条患者数据:')
|
||
|
for row in rows:
|
||
|
print(dict(row))
|
||
|
|
||
|
# 检查表结构
|
||
|
cursor.execute("PRAGMA table_info(patients)")
|
||
|
columns = cursor.fetchall()
|
||
|
print('\npatients表结构:')
|
||
|
for col in columns:
|
||
|
print(dict(col))
|
||
|
|
||
|
conn.close()
|