How to use JDBC Sqlite in Sikuli Script (Jython)
--- final solution:
see comment #22
-------
I tried to import sqlite3 into sikuli only to find I was getting import errors. After digging around a bit, it seems sqlite3 does not work in jython (correct me if im wrong?).
Anyway, does anyone know of anyway to connect to a database in sikuli?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply:
Related bugs
Related FAQ:
None Link to a FAQ
This question was reopened
- by Andrew Munro
- by Andrew Munro
- by Andrew Munro
Revision history for this message
![]() |
#1 |
Revision history for this message
![]() |
#2 |
Thanks, almost got it working. Are there any JDBC drivers built in to the sikuli jython instance or do I have to add my own.
If not, would I just download a driver.jar and then modify my batch script and add something like:
java -Xms64M -Xmx512M -Dfile.
Revision history for this message
![]() |
#3 |
Jython does not come with any DB drivers. Have to be added via class path parameter ( -cp on java command).
see: http://
Revision history for this message
![]() |
#4 |
Thanks RaiMan, that solved my question.
Revision history for this message
![]() |
#5 |
Hey, so after reading through the documentation, I tried two methods to import my java class.
The first being :
%JAVA_EXE% -Xms64M -Xmx512M -classpath "sqlite-jdbc.jar" ....
I also tried adding:
set CLASSPATH=
but I still get "zxJDBC.
I feel like I'm missing something obvious.
Revision history for this message
![]() |
#6 |
ok, now you are ready for question
https:/
ok, just a joke ;-)
simply forgot about that
Revision history for this message
![]() |
#7 |
... how did my searching not find this -_-
too early in the morning. Sorry :)
Revision history for this message
![]() |
#8 |
sometimes it is the trick, that you know what to search for ;-)
all the best.
Revision history for this message
![]() |
#9 |
Ok, tried experimenting for the last hour and still can't get this to work..(either windows command files suck or I do xD)
My normal bat script consists of:
@echo off
PATH=%PATH%
set JAVA_EXE="java"
set CLASSPATH=
if defined PROGRAMFILES(X86) set JAVA_EXE=
%JAVA_EXE% -Xms64M -Xmx512M -classpath "sqlite-jdbc.jar" -Dfile.
My driver is in the same directory as the .bat file as is my jython.jar that I downloaded.
I have tried the following:
set cp=sqlite-jdbc.jar
set cp=%cp%:jython.jar
java -cp %cp% org.python.
I do not understand the last part %1.sikuli/%1.py.
I could not get it to find sikuli :s
Revision history for this message
![]() |
#10 |
Exception in thread "main" java.lang.
Caused by: java.lang.
at java.net.
at java.security.
at java.net.
at java.lang.
at sun.misc.
at java.lang.
Could not find the main class: org.python.
FYI that is the error I have
Revision history for this message
![]() |
#11 |
--- I do not understand the last part %1.sikuli/%1.py.
Since you are using the Jython interpreter directly, you have to give it the .py file in the .sikuli folder.
--- just checked for Windows
the delimiter in class path between entries is ; (semicolon) and not : (colon)
--- easiest way to test (being in the folder that contains the sqlite-jdbc.jar)
java -cp "sqlite-
which opens an interactive Jython session.
first enter
from sikuli import *
to have access to Sikuli features
then import your driver and check functionality.
accoording to the mentioned question this should work.
If you send me the download link for the driver, I will check tomorrow on my Win 7
Revision history for this message
![]() |
#12 |
Ok confirmed that I could get it working in the jython shell, however I want it to execute and run my script with a single .bat
I tried:
%JAVA_EXE% -Xms64M -Xmx512M -cp "sqlite-
Finds my driver and connects fine!
But when I try to swap them round and put the jython in the cp and run the sikuli-ide with my startup script, it can't find the driver:
%JAVA_EXE% -Xms64M -Xmx512M -cp "sqlite-
Im going to do a little reading into java parameters, but im puzzled as to how I execute sikuli automatically with jython.
Revision history for this message
![]() |
#13 |
no need to run a ready script using sikuli-ide.bat
try this:
java -cp "sqlite-
BTW: avoid any special characters in Sikuli script file names.
so better: runSuite.sikuli
Revision history for this message
![]() |
#14 |
or even this (since sikuli-script.jar is already in cp):
java -cp "sqlite-
There might be an error message when script ends (something about cannot run ...): just ignore it ;-)
Revision history for this message
![]() |
#15 |
Nope, still can't find the driver. Im confused now, I thought I had to add jython to my cp or something?
Using:
%JAVA_EXE% -cp "sqlite-
I:\QA\sikuli>
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
[error] Can't run this Sikuli script: run_suite.sikuli
Traceback (most recent call last):
File "I:\QA\
conn = zxJDBC.
zxJDBC.
Code:
filename = dubit.config_
from com.ziclix.
conn = zxJDBC.
I am remebering back to when my friend suggested using a database to store my results data. "It will be 3 lines of python!" he said... "it will be easy"... he said xD
Revision history for this message
![]() |
#16 |
Ok, I tried this:
%JAVA_EXE% -Xms64M -Xmx512M -cp "sqlite-
Couldn't find my driver and also gave me a load of cpython import errors (e.g No module named OS)
Revision history for this message
![]() |
#17 |
Ok, I tried this:
%JAVA_EXE% -Xms64M -Xmx512M -cp "sqlite-
Couldn't find my driver and also gave me a load of cpython import errors (e.g No module named OS)
Revision history for this message
![]() |
#18 |
what about suggestion in comment #14 ?
and this might work
java -cp "sqlite-
but the the script needs a
from sikuli import *
at beginning
and you have to take care for your images (e.g. setBundlePath correctly or add image path)
--- Im confused now, I thought I had to add jython to my cp or something?
no need for that, jython 2.5.2 is contained in sikuli-script.jar
--- I am remebering back to when my friend suggested using a database to store my results data. "It will be 3 lines of python!" he said... "it will be easy"... he said xD
Did your friend know, that you wanted to use Sikuli together with JDBC ?
The 3 lines are not the problem - problem is the one line, that runs your stuff using Java ;-)
Revision history for this message
![]() |
#19 |
Again:
If you send me the download link for the driver, I will check tomorrow on my Win 7
Revision history for this message
![]() |
#21 |
http://
Driver works fine because it worked in the jython shell :3
Revision history for this message
![]() |
#22 |
Hey it works!!!!
%JAVA_EXE% -Xms64M -Xmx512M -cp "sqlite-
I made a stupid error and didn't use your solution properly. I still tried the .jar rather than org.sikuli.
Thanks for all your help RaiMan, you're a lifesaver :)
Revision history for this message
![]() |
#23 |
Thanks RaiMan, that solved my question.