Files
njts-accounting-core/list_accounts.py
2026-02-21 10:51:25 +09:00

11 lines
343 B
Python

#!/usr/bin/env python3
import psycopg
conn = psycopg.connect('host=localhost user=postgres password=postgres dbname=accounting')
cur = conn.cursor()
cur.execute('SELECT account_code, account_name FROM accounts WHERE is_active=true ORDER BY account_code')
for row in cur.fetchall():
print(f'{row[0]:3s} {row[1]}')
cur.close()
conn.close()