#!/usr/bin/env python3 """ Check COMENZI table structure """ import oracledb import os from dotenv import load_dotenv load_dotenv('.env') user = os.environ['ORACLE_USER'] password = os.environ['ORACLE_PASSWORD'] dsn = os.environ['ORACLE_DSN'] try: instantclient_path = os.environ.get('INSTANTCLIENTPATH', '/opt/oracle/instantclient_23_9') oracledb.init_oracle_client(lib_dir=instantclient_path) except Exception as e: pass def check_table_structure(): """Check COMENZI table columns""" print("🔍 Checking COMENZI table structure...") try: with oracledb.connect(user=user, password=password, dsn=dsn) as conn: with conn.cursor() as cur: # Get table structure cur.execute(""" SELECT column_name, data_type, nullable, data_length, data_precision FROM user_tab_columns WHERE table_name = 'COMENZI' ORDER BY column_id """) columns = cur.fetchall() if columns: print(f"\nCOMENZI table columns:") for col in columns: nullable = "NULL" if col[2] == 'Y' else "NOT NULL" if col[1] == 'NUMBER' and col[4]: type_info = f"{col[1]}({col[4]})" elif col[3]: type_info = f"{col[1]}({col[3]})" else: type_info = col[1] print(f" {col[0]}: {type_info} - {nullable}") # Look for partner-related columns print(f"\nPartner-related columns:") for col in columns: if 'PART' in col[0] or 'CLIENT' in col[0]: print(f" {col[0]}: {col[1]}") except Exception as e: print(f"❌ Check failed: {e}") def main(): print("🔍 COMENZI Table Structure") print("=" * 40) check_table_structure() if __name__ == "__main__": main()