ā05-11-2023 06:13 AM
Hi,
Trying to access a distant SQL database from a workflow, I'm unable to import relevant python module. Is this natively possible or should I installed additionnal python module ? And if yes, how ? Older post talk about former XMC, but seems not to be effective in XIQ-SE.
Regards.
Jave
Solved! Go to Solution.
ā05-12-2023 06:39 AM
Officially I do not think there is a means to import modules in either Python or Jython as used by XMC/XIQ-SE.
XMC/XIQ-SE includes python2.7/python3 command line interpreters but primarily uses Jython - a Java-based python interpreter for its GUI-based Python script executions.
While it's likely possible to tweak the system to use pip, etc to import modules for either I do not think formally this is supported.
To add formal support would be a product enhancement / feature request.
ā05-14-2023 11:44 PM
You may consider using the build-in driver. more details in the XIQ-SE licensing calculation workflow:
from com.ziclix.python.sql import zxJDBC
try:
cnxn = zxJDBC.connect(url,emc_vars["dbUser"], emc_vars["dbPassword"], driver)
mycursor = cnxn.cursor()
mycursor.close()
cnxn.close()
except:
status = emc_results.Status;
emc_results.setStatus( status.ERROR )
emc_results.put("workflowMessage","MySQL Database access issue, check the password in Variables!")
wf_error("MySQL Database access issue, check the password in Variables!")
else:
wf_info("MySQL Database access OK.")
2 weeks ago
Hi,
If you replace the MySQL driver with PSQL driver you should be able to re-use majority of the workflow. basic SQL commands are the same for MySQL and PSQL...
from com.ziclix.python.sql import zxJDBC
# Try the DB connection and if it is not successful than stop
url = 'jdbc:postgresql://localhost:4589/netsight' #URL with port and database name
driver = 'org.postgresql.Driver'
try:
cnxn = zxJDBC.connect(url,emc_vars["dbUser"], emc_vars["dbPassword"], driver)
mycursor = cnxn.cursor()
mycursor.close()
cnxn.close()
except:
status = emc_results.Status;
emc_results.setStatus( status.ERROR )
emc_results.put("workflowMessage","Database access issue, check the password in Variables!")
else:
print ("Database access OK.")
2 weeks ago
Yes. I have created a workflow which execute SQL request towards a MySQL database in order to retrieve provisionning's datas for a ZTP+ discovered device, like it's management IP and VLAN, it's name and many others parameters. This database is provisionned via a web interface by network administrators. If MySQL driver is not available anymore I would be forced to modify all my setup...
Regards.
2 weeks ago
Hi,
If you replace the MySQL driver with PSQL driver you should be able to re-use majority of the workflow. basic SQL commands are the same for MySQL and PSQL...
from com.ziclix.python.sql import zxJDBC
# Try the DB connection and if it is not successful than stop
url = 'jdbc:postgresql://localhost:4589/netsight' #URL with port and database name
driver = 'org.postgresql.Driver'
try:
cnxn = zxJDBC.connect(url,emc_vars["dbUser"], emc_vars["dbPassword"], driver)
mycursor = cnxn.cursor()
mycursor.close()
cnxn.close()
except:
status = emc_results.Status;
emc_results.setStatus( status.ERROR )
emc_results.put("workflowMessage","Database access issue, check the password in Variables!")
else:
print ("Database access OK.")
2 weeks ago
I've already do that few hours ago, it works. I unfortunately had to rewrite my php code for the web application for provisioning the database in question. But no problem, everything works correctly now.
Regards.
ā05-15-2023 05:32 AM
Hi @ZdenÄk_Pala ,
I had actually seen your workflow working through system calls but I was not aware of this built-in driver: thank you very much, it meets my needs !
Regards,
Jave
ā05-12-2023 06:39 AM
Officially I do not think there is a means to import modules in either Python or Jython as used by XMC/XIQ-SE.
XMC/XIQ-SE includes python2.7/python3 command line interpreters but primarily uses Jython - a Java-based python interpreter for its GUI-based Python script executions.
While it's likely possible to tweak the system to use pip, etc to import modules for either I do not think formally this is supported.
To add formal support would be a product enhancement / feature request.