sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #48234
Re: [Question #672153]: [HowTo] access SQL Server 12.0.5207 on a Windows Server VM
Question #672153 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/672153
Description changed to:
************ only works up-to 1.1.3
for 1.1.4: bug 1789569
**** the solution from comment #6 --- thanks to the provider ***************
The "missing link" was the Microsoft JDBC Driver 7.0 for SQL Server. I downloaded the jar from them here:
https://docs.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-2017
(which directs you to here: https://www.microsoft.com/en-us/download/details.aspx?id=57175)
The jar file referenced in my "load" command after the imports.
So far it appears to be working well!
By the way, this is connecting to SQL Server 12.0.5207 on a Windows
Server VM.
Thought that I would share it in case someone else needed help with this
as well.
Thanks for your help, Raiman!
Ron
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
from com.ziclix.python.sql import zxJDBC
import datetime
import sys
load("C:\Users\BYE8557\Documents\SQLJDBC\sqljdbc_7.0\enu\mssql-
jdbc-7.0.0.jre8.jar")
conn = None
d, u, p, v = "jdbc:sqlserver://yourservername", "youruserid",
"yourpassword", "com.microsoft.sqlserver.jdbc.SQLServerDriver"
try:
conn = zxJDBC.connect(d, u, p, v)
cursor = conn.cursor()
cursor.execute("SELECT * FROM dbname.dbo.tablename as a WHERE
a.fieldone = 'sometext' and a.fieldtwo = somevalue")
print cursor.fetchone()
print "DB Name: " + conn.dbname
print "DB Version: " + conn.dbversion
print "Driver Name: " + conn.drivername
print "Driver Version: " + conn.driverversion
print "Database URL: " + str(conn.url)
print "Connection info: " + str(conn.__connection__)
print "Is connection closed? -> " + str(conn.closed)
conn.close()
except:
exc_type, exc_val, exc_tb = sys.exc_info()
ErrorText = "***** ERROR IN SCRIPTNAME = " + sys.argv[0] + " *****\n"
ErrorText += "Date/Time : " + str(datetime.datetime.now()) + "\n"
ErrorText += "Line Number: " + str(exc_tb.tb_lineno) + "\n"
ErrorText += "Error Type : " + exc_type.__name__ + "\n"
ErrorText += "Error Value: " + exc_val.message + "\n"
ErrorText += "***************************************************************\n\r"
print ErrorText
-----------------------------------------------------------------------------------------------------------
I am running Windows 7.
I have SIkuliX 1.1.2 installed.
I have Python 2.7 installed (C:\Python27)
I have installed pyodbc via pip.
I added a "sites.txt" file per instructions in found in the "Answers" forum.
The file is located under my AppData folder here:
C:\Users\Ron\AppData\Roaming\Sikulix\Lib\site-packages
The sites.txt file contains only the following line:
C:\Python27\Lib\site-packages\
I placed the line "import pyodbc" in my script, but when I run it I receive a traceback error that states:
"ImportError: No module named pyodbc"
I thought that perhaps the pyodbc driver wasn't properly installed, so I tried running the pip again, but it reported:
"Requirement already satisfied: pyodbc in c:\python27\lib\site-packages"
I'm obviously doing something wrong. Please let me know how I can get
this working.
Thanks in advance!
Ron
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.