43 lines
986 B
Python
43 lines
986 B
Python
#!/usr/bin/env python
|
|
"""Direct SQL query to check unit_level"""
|
|
import sys
|
|
import os
|
|
import pg8000
|
|
|
|
# Add project root to path
|
|
project_root = os.path.abspath(os.path.dirname(__file__))
|
|
sys.path.insert(0, project_root)
|
|
|
|
# Load .env
|
|
from lawrisk.utils.env_loader import load_env
|
|
load_env('.env', override=False)
|
|
|
|
# Connect
|
|
conn = pg8000.connect(
|
|
host=os.getenv('LIC_PG_HOST'),
|
|
port=int(os.getenv('LIC_PG_PORT', '5432')),
|
|
user=os.getenv('LIC_PG_USER'),
|
|
password=os.getenv('LIC_PG_PASSWORD'),
|
|
database=os.getenv('LIC_PG_DATABASE')
|
|
)
|
|
cur = conn.cursor()
|
|
|
|
print("=" * 60)
|
|
print("Direct SQL Query Results")
|
|
print("=" * 60)
|
|
print()
|
|
|
|
cur.execute("""
|
|
SELECT code, name, unit_level, grade
|
|
FROM service_departments
|
|
ORDER BY code
|
|
""")
|
|
|
|
for row in cur.fetchall():
|
|
code, name, unit_level, grade = row
|
|
print(f"{code}: {name}")
|
|
print(f" unit_level={unit_level}, grade={grade}")
|
|
|
|
conn.close()
|
|
print("\n" + "=" * 60)
|