60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
import os
|
|
import psycopg2
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from root .env
|
|
root_env = os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env')
|
|
load_dotenv(root_env)
|
|
|
|
# Connect to database
|
|
conn = psycopg2.connect(
|
|
host=os.getenv('DB_HOST', '192.168.0.61'),
|
|
port=os.getenv('DB_PORT', '55432'),
|
|
dbname=os.getenv('DB_NAME', 'njts_acct'),
|
|
user=os.getenv('DB_USER', 'njts_app'),
|
|
password=os.getenv('DB_PASSWORD')
|
|
)
|
|
|
|
cur = conn.cursor()
|
|
|
|
# Check current column precision
|
|
cur.execute("""
|
|
SELECT column_name, data_type, numeric_precision, numeric_scale
|
|
FROM information_schema.columns
|
|
WHERE table_name='insurance_rates'
|
|
AND column_name IN ('employee_rate', 'employer_rate')
|
|
ORDER BY column_name
|
|
""")
|
|
|
|
print("insurance_rates カラムの現在の精度:")
|
|
for row in cur.fetchall():
|
|
print(f" {row[0]}: {row[1]}({row[2]},{row[3]})")
|
|
|
|
# Check child_support_contribution_rates
|
|
cur.execute("""
|
|
SELECT column_name, data_type, numeric_precision, numeric_scale
|
|
FROM information_schema.columns
|
|
WHERE table_name='child_support_contribution_rates'
|
|
AND column_name = 'contribution_rate'
|
|
""")
|
|
|
|
print("\nchild_support_contribution_rates カラムの現在の精度:")
|
|
for row in cur.fetchall():
|
|
print(f" {row[0]}: {row[1]}({row[2]},{row[3]})")
|
|
|
|
# Check actual data
|
|
cur.execute("""
|
|
SELECT rate_year, rate_type, calculation_target, prefecture,
|
|
employee_rate, employer_rate
|
|
FROM insurance_rates
|
|
WHERE rate_year = 2025 AND rate_type = '健康保険'
|
|
LIMIT 3
|
|
""")
|
|
|
|
print("\n実際のデータ (2025年健康保険):")
|
|
for row in cur.fetchall():
|
|
print(f" {row[0]} {row[1]} {row[2]} {row[3]}: 従業員={row[4]} 会社={row[5]}")
|
|
|
|
cur.close()
|
|
conn.close()
|