#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json result = {} try: dbname = get_module_dbname('opportunity_management') async with DBPools().sqlorContext(dbname) as sor: ns = {'page': 1, 'rows': 50, 'sort': 'COLUMN_NAME'} for tbl in ['opportunities', 'sales_stages']: sql = f"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='crm_db' AND TABLE_NAME='{tbl}'" rows = await sor.sqlExe(sql, ns) if isinstance(rows, dict): rows = rows.get('rows', []) result[tbl] = [dict(r).get('column_name', '') for r in rows] result['success'] = True except Exception as e: result['error'] = str(e) return json.dumps(result, ensure_ascii=False, default=str)