LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-24-2016, 08:01 PM   #1
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Rep: Reputation: Disabled
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
 
Old 11-27-2016, 08:42 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 23,815

Rep: Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974Reputation: 6974
Quote:
Originally Posted by barathan View Post
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/
 
Old 11-27-2016, 10:14 PM   #3
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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

Last edited by barathan; 11-28-2016 at 02:29 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] making a timer class in python Nabeel Programming 1 12-31-2012 01:29 PM
Which process is making DNS queries? TruckStuff Linux - Networking 4 11-29-2005 04:05 PM
python queries LAdProg2005 Programming 0 11-14-2005 10:38 AM
Making a Python program gamehack Programming 0 04-11-2004 05:12 AM
SQL: making queries from multiple tables ganninu Programming 1 01-08-2004 11:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration