#!/usr/bin/env python3 """ Apply the no-logging fix to gaseste_articol_roa """ 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 apply_fix(): """Apply the no-logging fix""" print("🔧 Applying no-logging fix to gaseste_articol_roa...") # Read the fix SQL with open('/app/fix_gaseste_articol.sql', 'r') as f: fix_sql = f.read() try: with oracledb.connect(user=user, password=password, dsn=dsn) as conn: with conn.cursor() as cur: # Execute the fix cur.execute(fix_sql) print("✅ No-logging package applied successfully") # Test the fixed function cur.execute(""" SELECT * FROM TABLE(PACK_IMPORT_COMENZI.gaseste_articol_roa('CAF01', 25.0, 1)) """) results = cur.fetchall() print(f"✅ Fixed function test: {len(results)} results") for result in results: print(f" Success: {result[4]}, CODMAT: {result[1]}") return True except Exception as e: print(f"❌ Apply fix failed: {e}") return False def main(): apply_fix() if __name__ == "__main__": main()