How to import cx_Oracle library into python SikuliX script --- not possible (C-based) --- workaround
******************* workarounds
see comment #3 following
-------
Hi guys,
I'm trying to import cx_Oracle library into my python test script inside sikulix, however I'm getting this error:
[error] script [ connect_and_print ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\BRX Retail\
My imports are:
import random
import org.sikuli.
import cx_Oracle
Can you guys help me?
Thanks,
Antonio
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Sikuli Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- 2019-02-12
- Last query:
- 2019-02-12
- Last reply:
- 2019-02-12
RaiMan (raimund-hocke) said : | #1 |
Supposing the module cx_Oracle is in a place, where it can be found by SikuliX (containing folder is in sys.path).
Sorry, but since SikuliX is Java based using the Jython interpreter, only Python modules written in plain Python language can be imported.
cx_Oracle seems to depend on native libraries, which means it contains C-based code, which leads to the ImportError: No module named cx_Oracle
Hi RaiMan,
First off all thanks for answering.
And if I use another dev tool like Sublime and try to import sikulix inside that tool, or something in this line?
Thanks.
RaiMan (raimund-hocke) said : | #3 |
cx_Oracle only works with Python (C-based Python), but from there you cannot use SikuliX directly, but only with some Python-Java wrapping (like pyjnius).
So if you need direct access to your DB during scriptrun, then it will be a stony way - may be impossible.
If acceptable: write what you need from your DB to a CSV-file and use that in your script.
Surely there might be other workarounds, like running Python scripts from SikuliX using subprocess, that return some stuff to be used in the script.
Thanks man,
I found this question https:/
[error] Error caused by: Traceback (most recent call last): File "C:\Users\BRX Retail\
at java.util.
at java.util.
at java.util.
at java.lang.
at org.sikuli.
at org.sikuli.
at org.sikuli.
at org.sikuli.
at org.sikuli.
at org.sikuli.
at sun.reflect.
at sun.reflect.D
elegatingMethod
at java.lang.
java.util.
This is my script:
python = r"C:\Users\BRX Retail\
pyscript = r"C:\Users\BRX Retail\
cmd = "%s %s" % (python, pyscript)
result = run(cmd)
print(result)
#teste.py
import cx_Oracle
# Connect as user "hr" with password "welcome" to the "oraclepdb" service running on this computer.
con = cx_Oracle.
#cursor = con.cursor()
#cursor.execute("""
# SELECT *
# FROM table
# """)
#res = cursor.
print("BLABLA")
You already see this?
Thanks
RaiMan (raimund-hocke) said : | #5 |
python = r"C:\Users\BRX Retail\
... a raw string can not end with a \
try:
python = r"C:\Users\BRX Retail\
Nice!
It works, but now we've permission problems:
[error] RunTimeIDE: fatal error: java.io.
9999
*****error*****
java.io.
The strage is all this folders are with full permissions.
|
#7 |
Add an extension?
.exe?
Good one hahah
Now it works, thanks RaiMan (:
I'll close this question!
Thanks RaiMan, that solved my question.