#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sqlite3

conn = sqlite3.connect('database/kdrug.db')
cursor = conn.cursor()

# 테이블 목록 확인
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")
tables = cursor.fetchall()

print("=== 전체 테이블 목록 ===")
for table in tables:
    print(f"  - {table[0]}")

print("\n=== inventory_lots 테이블 구조 ===")
cursor.execute("PRAGMA table_info(inventory_lots)")
columns = cursor.fetchall()
for col in columns:
    print(f"  {col[1]}: {col[2]}")

print("\n=== inventory_lots 샘플 데이터 ===")
cursor.execute("""
    SELECT lot_id, lot_number, herb_item_id, quantity_onhand,
           unit_price_per_g, received_date, receipt_id
    FROM inventory_lots
    WHERE is_depleted = 0
    LIMIT 5
""")
rows = cursor.fetchall()
for row in rows:
    print(f"  LOT {row[0]}: {row[1]}, 재고:{row[3]}g, 단가:₩{row[4]}, 입고일:{row[5]}, receipt_id:{row[6]}")

conn.close()