Hello all,
This is my first time posting here, so apologies in advance for any mistakes.
I'm trying to run a Python script in SAM that should execute a query on an MSSQL instance. It works properly when I run it directly on the Linux server, but when I try to run it in Orion, the error "Testing on target node failed with 'Down' status ('Down' might be different if the script exits with a different exit code)" appears.
I have some other Python scripts running fine, so I believe I know the output syntax and don't think that's the issue. If anyone has any idea about what's wrong, I would appreciate it. Please find more information below:
- Script output error:

- An exemple of another script running well:

- My script result running directly in the Linux server:

- My script text:
import pyodbc
def conecta_ao_banco(driver="ODBC Driver 18 for SQL Server", server="MYDBSERVER\SOLARWINDS_ORION", database="SolarWindsOrion", username="tst", password="tst", trusted_connection="no", trustservercertificate="yes"):
string_conexao = f"DRIVER={driver};SERVER={server};DATABASE={database};UID={username};PWD={password};TRUSTED_CONNECTION={trusted_connection};TRUSTSERVERCERTIFICATE={trustservercertificate}"
conexao = pyodbc.connect(string_conexao)
cursor = conexao.cursor()
return conexao, cursor
conexao, cursor = conecta_ao_banco()
result = cursor.execute("SELECT total_size_mb = CAST (SUM (size) * 8. / 1024 AS DECIMAL (8,0)), database_name = DB_NAME (database_id) FROM sys.master_files WHERE DB_NAME (database_id) = 'SolarWindsOrion' GROUP BY database_id;").fetchall()
print(f"Statistic.Status: {result[0][0]}")