LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   making DB queries from Linux to windows using python pyodbc (https://www.linuxquestions.org/questions/linux-software-2/making-db-queries-from-linux-to-windows-using-python-pyodbc-4175594193/)

barathan 11-24-2016 08:01 PM

making DB queries from Linux to windows using python pyodbc
 
Hello Guys, im a real newbie in this, but however, what im trying to do is i want to connect to a DB in a windows machine from my linux Opensuse13.2, using python pyodbc. below is my code :

Code:

pyodbc.connect('DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=userid;PWD=password')
the exact error i got was as below : pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")

and below is my odbcinst.ini file :

Code:

[Easysoft ODBC-SQL Server]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
UsageCount=2

[Easysoft ODBC-SQL Server SSL]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv_ssl.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
UsageCount=2

please help me to sort this out.Please assist me to find the root cause. please do let me know what information you need from me that will help to find the root cause

TB0ne 11-27-2016 08:42 AM

Quote:

Originally Posted by barathan (Post 5634301)
Hello Guys, im a real newbie in this,

...except for the fact you've been here for FOUR YEARS, and have been asking about Python scripts that long as well???
Quote:

but however, what im trying to do is i want to connect to a DB in a windows machine from my linux Opensuse13.2, using python pyodbc. below is my code:
Code:

pyodbc.connect('DRIVER={SQL Server};SERVER=servername;DATABASE=dbname;UID=userid;PWD=password')
the exact error i got was as below : pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")

and below is my odbcinst.ini file :

Code:

[Easysoft ODBC-SQL Server]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
UsageCount=2

[Easysoft ODBC-SQL Server SSL]
Driver=/usr/local/easysoft/sqlserver/lib/libessqlsrv_ssl.so
Setup=/usr/local/easysoft/sqlserver/lib/libessqlsrvS.so
Threading=0
FileUsage=1
DontDLClose=1
UsageCount=2

please help me to sort this out.Please assist me to find the root cause. please do let me know what information you need from me that will help to find the root cause
You posted ONE LINE of your code...we can't tell you anything based on it. Did you import the pyodbc module? Did you try to read the documentation on it?
https://mkleehammer.github.io/pyodbc/

barathan 11-27-2016 10:14 PM

i'm marking this as solved.

it is not really a question related to python. realizing the fact that i'm working with python for the past 4 years, of course i imported the pyodbc script. otherwise the failure message would have been different. its a question related to Linux ODBC driver configuration...

just in case anyone came across this problem, this is how i solved my problem. for some reason, after installing an ODBC driver, (here's a link for an ODBC driver, that works like a champ : https://blogs.msdn.microsoft.com/dil...on-suse-linux/) the odbc.ini and odbcinst.ini files were located at /etc/. however, to make sure the location is correct, please run this command : "odbcinst -j", and you will see below output :


Code:

MyTester:~ # odbcinst -j
unixODBC 2.3.2
DRIVERS............: /etc/unixODBC/odbcinst.ini
SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini
FILE DATA SOURCES..: /etc/unixODBC/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
MyTester:~ #


so basically, in my case, the files should be at /etc/unixODBC/odbcinst.ini/ instead of /etc/. so i just copied the files to /etc/unixODBC/odbcinst.ini/ and it works! good luck guys


All times are GMT -5. The time now is 07:35 AM.