How to access SQL databases using the JDBC driver library

Asked by haj

I'm having trouble getting sikuli with python, I'm trying to import python module in sikuli, but i became an error:

[error] ImportError ( No module named pyodbc )

I have made connection with SQL Server in python and i want to import this script in sikuli.

 Can you help me pls.

Thank you,
haj

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1

My sample codes may help you.
This is using zxJDBC to access SQLite3 Database.
When you want to access SQL Server, you have to change such as JDBC driver.

[sample codes:]
load("C:\jdbcdriver\sqlite-jdbc-3.8.6.jar")
from com.ziclix.python.sql import zxJDBC

url = "jdbc:sqlite:c:/sqlitedb/sample.db3"
dbuser = ""
dbpassword = ""
driver = "org.sqlite.JDBC"

dbconn = zxJDBC.connect(url, dbuser, dbpassword, driver)
dbcur = dbconn.cursor()

try:
    dbcur.execute("select id, name from member")
    rs = dbcur.fetchall()
    for elm in rs:
        print elm[0], elm[1]

except Exception, e:
    print e.args[0]

finally:
    dbcur.close()
    dbconn.close()

Revision history for this message
haj (haj31) said :
#2

Hello Masuo,

Thank you for the code, but i still have errors:

[error] zxJDBC.DatabaseError ( driver [org.sqlite.JDBC] not found )

I have downloaded zxJDBC and sqljdbc4.jar but it doesn't work.

Thanks,
haj

Revision history for this message
haj (haj31) said :
#3

I need help

Revision history for this message
masuo (masuo-ohara) said :
#4

In case of SQLServer, driver is com.microsoft.sqlserver.jdbc.SQLServerDriver.
Sorry, I have no idea any more.
I run my sample codes by Sikuli-IDE.
sikulix.jar include zxJDBC package, so I have not downloaded zxJDBC.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

To get masuo's results, you need SikuliX version 1.1.1.

Revision history for this message
haj (haj31) said :
#6

Thank you @masou and @RaiMan

Can you help with this problem?

Provide an answer of your own, or ask haj for more information if necessary.

To post a message you must log in.