gateway/scripts/_listMandates.py
2026-04-25 01:13:01 +02:00

25 lines
1.2 KiB
Python

import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import psycopg2, psycopg2.extras
from modules.shared.configuration import APP_CONFIG
c = psycopg2.connect(
host=APP_CONFIG.get('DB_HOST','localhost'),
user=APP_CONFIG.get('DB_USER'),
password=APP_CONFIG.get('DB_PASSWORD_SECRET'),
port=int(APP_CONFIG.get('DB_PORT',5432)),
dbname='poweron_app',
)
cur = c.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cur.execute('SELECT id, name, label, enabled, "deletedAt", "sysCreatedAt" FROM "Mandate" ORDER BY "sysCreatedAt"')
print("All Mandates in poweron_app:")
for r in cur.fetchall():
print(f" id={r['id']} name={r['name']} label={r['label']} enabled={r['enabled']} deletedAt={r['deletedAt']}")
cur.execute('SELECT COUNT(*) AS n FROM "FeatureInstance" WHERE "featureCode" = %s', ("redmine",))
print(f"\nTotal redmine FeatureInstances in poweron_app: {cur.fetchone()['n']}")
cur.execute('SELECT id, "mandateId", label, enabled FROM "FeatureInstance" WHERE "featureCode" = %s ORDER BY "sysCreatedAt"', ("redmine",))
for r in cur.fetchall():
print(f" fi={r['id']} mandate={r['mandateId']} label={r['label']} enabled={r['enabled']}")