37 lines
858 B
Python
37 lines
858 B
Python
import psycopg
|
|
from psycopg.rows import dict_row
|
|
|
|
# データベース接続
|
|
conn = psycopg.connect(
|
|
host="192.168.0.61",
|
|
port=55432,
|
|
dbname="njts_acct",
|
|
user="njts_app",
|
|
password="njts_app2025",
|
|
row_factory=dict_row
|
|
)
|
|
|
|
# SQLファイルを読み込んで実行
|
|
with open('sql/add_my_number_field.sql', encoding='utf-8') as f:
|
|
sql = f.read()
|
|
|
|
cur = conn.cursor()
|
|
cur.execute(sql)
|
|
conn.commit()
|
|
|
|
print("マイナンバーフィールドの追加が完了しました")
|
|
|
|
# 確認
|
|
cur.execute("""
|
|
SELECT column_name, data_type, character_maximum_length
|
|
FROM information_schema.columns
|
|
WHERE table_name = 'employees' AND column_name = 'my_number'
|
|
""")
|
|
result = cur.fetchone()
|
|
if result:
|
|
print(f"✓ フィールド追加確認: {result}")
|
|
else:
|
|
print("✗ フィールドが見つかりません")
|
|
|
|
conn.close()
|