This commit is contained in:
admin
2026-02-21 10:51:25 +09:00
parent 584530937b
commit 3b028b8fc0
25 changed files with 1852 additions and 244 deletions

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""opening_balances テーブルのデータ確認"""
import psycopg
try:
conn = psycopg.connect('host=localhost user=postgres password=postgres dbname=accounting')
cur = conn.cursor()
# opening_balances テーブルの行数確認
cur.execute("SELECT COUNT(*) FROM opening_balances")
count = cur.fetchone()[0]
print(f"【opening_balances テーブル行数】: {count}")
if count == 0:
print("\n⚠️ opening_balances テーブルは空です")
print("→ 期首残高データが入力されていません")
else:
# 年度別データを確認
cur.execute("SELECT fiscal_year, COUNT(*) as cnt FROM opening_balances GROUP BY fiscal_year ORDER BY fiscal_year")
print("\n【年度別件数】")
for row in cur.fetchall():
print(f" {row[0]}年度: {row[1]}")
# 2025年度のサンプルデータ
print("\n【2025年度のサンプル最初の5件")
cur.execute("""
SELECT account_id, opening_debit, opening_credit
FROM opening_balances
WHERE fiscal_year = 2025
LIMIT 5
""")
for row in cur.fetchall():
print(f" account_id={row[0]}, debit={row[1]}, credit={row[2]}")
cur.close()
conn.close()
except Exception as e:
print(f"❌ エラー: {e}")