pharmacy-pos-qr-system/backend/check_paai_status.py

41 lines
1.2 KiB
Python

import sqlite3
import os
db_path = 'db/paai_logs.db'
print(f"DB 경로: {os.path.abspath(db_path)}")
print(f"파일 존재: {os.path.exists(db_path)}")
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
# 모든 테이블 확인
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
all_tables = [t[0] for t in cursor.fetchall()]
print(f"전체 테이블: {all_tables}")
for table in all_tables:
cursor.execute(f"SELECT COUNT(*) FROM {table}")
count = cursor.fetchone()[0]
print(f"\n=== {table}: {count}건 ===")
# 컬럼 정보
cursor.execute(f"PRAGMA table_info({table})")
cols = [c[1] for c in cursor.fetchall()]
print(f"컬럼: {cols}")
# status 컬럼이 있으면 상태별 카운트
if 'status' in cols:
cursor.execute(f"SELECT status, COUNT(*) FROM {table} GROUP BY status")
for row in cursor.fetchall():
print(f" {row[0]}: {row[1]}")
# 최근 5건
cursor.execute(f"SELECT * FROM {table} ORDER BY rowid DESC LIMIT 3")
rows = cursor.fetchall()
if rows:
print(f"최근 3건:")
for row in rows:
print(f" {row}")
conn.close()