This commit is contained in:
admin
2026-02-20 15:47:27 +09:00
parent c60cbf2d9a
commit 584530937b
108 changed files with 12112 additions and 416 deletions

50
check_table_schema.py Normal file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
sys.path.insert(0, 'backend')
os.environ['DB_HOST'] = '192.168.0.61'
os.environ['DB_NAME'] = 'njts_acct'
os.environ['DB_USER'] = 'njts_app'
os.environ['DB_PASSWORD'] = 'njts_app2025'
os.environ['DB_PORT'] = '55432'
from app.core.database import get_connection
with get_connection() as conn:
with conn.cursor() as cur:
print('\n【 journal_lines 表结构 】')
cur.execute("""
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'journal_lines'
ORDER BY ordinal_position
""")
for row in cur.fetchall():
print(f'{row["column_name"]:<20} {row["data_type"]:<15} {row["is_nullable"]}')
print('\n【 journal_lines 前5条数据 】')
cur.execute("SELECT * FROM journal_lines LIMIT 5")
cols = [desc[0] for desc in cur.description]
print('\t'.join(cols))
for row in cur.fetchall():
print('\t'.join(str(v) for v in row))
print('\n【 accounts 表结构 】')
cur.execute("""
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'accounts'
ORDER BY ordinal_position
""")
for row in cur.fetchall():
print(f'{row["column_name"]:<20} {row["data_type"]:<15} {row["is_nullable"]}')
print('\n【 accounts 数据示例 】')
cur.execute("SELECT account_id, account_code, account_name FROM accounts WHERE account_code IN ('701', '601') LIMIT 5")
cols = [desc[0] for desc in cur.description]
print('\t'.join(cols))
for row in cur.fetchall():
print('\t'.join(str(v) for v in row))