Question
· Oct 24, 2023

Python: is it possible to compile/reload the Production without using a connection to the IRIS database?

import os

# Get environment variables
db_host = os.getenv('DB_HOST')
db_port = os.getenv('DB_PORT')
db_namespace = os.getenv('DB_NAMESPACE')
db_username = os.getenv('DB_USERNAME')
db_password = os.getenv('DB_PASSWORD')

# Create a database connection
conn = irisnative.createConnection(db_host, db_port, db_namespace, db_username, db_password)

# Create an IRIS instance from this connection
iris_native = irisnative.createIris(conn)

status = iris_native.classMethodValue('%SYSTEM.OBJ', 'Load', 'Production.cls', 'ck')

if status == 1:
    print("The Production.cls file was compiled successfully.")
else:
    print("An error occurred while compiling the Production.cls file.")


This Python code works perfectly but I am looking for another alternative without creating a connection to IRIS in order to avoid any security breach

Product version: IRIS 2023.2
$ZV: IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2023.2 (Build 227U)
Discussion (3)2
Log in or sign up to continue

It looks like Production.cls is a production class which is loaded into and compiled within the IRIS data platform.  You would need a connection in order to load and compile the code.  I am not sure what you mean by compiling the code (which required IRIS) without a connection to IRIS?  Can you please explain more about what you are trying to accomplish?   

Instead of doing it this way, you can make it even with less code, using Python Embedded

import iris

status = iris.cls('%SYSTEM.OBJ').Load("Production.cls","ck")

# It could be just like this, but OBJ not there 
# https://github.com/intersystems-community/embedded-python-bugreports/issues/2
# iris.system.OBJ.Load("Production.cls","ck")