Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to windows SQL Server from Ubuntu

For the past two days I have been trying to connect to a remote windows SQL server with no apparent success. I am trying to connect with python using the pyodbc package.

I have tried following all the blog posts out there for that matter without much luck. I first followed that one which I think makes a good effort but ends up being too incoherent IMO.

I have installed the unixODBC manager as proposed in the blog post. I have downloaded the available redhat packages from Windows and run the installation scripts but every time I try to connect to the db I get

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server Native Client 10.0' : file not found (0) (SQLDriverConnect)")

Is there a way to achieve that in a matter of hours without having to adjust window's installation scripts myself? Can someone provide an overview of the steps that need to be taken and the modules that need to be installed in order for someone to be able to connect to windows SQL server from a linux machine?

I am currently using Ubuntu 15.04.

Update

I also tried the instructions given here. Looking at the details of the SQL db in the azure platform it is explicitly stated that the driver should be SQL Server Native Client 10.0. Should I consider mandatory using that driver or can I use for example FreeTDS as suggested in the second blog post?

like image 681
LetsPlayYahtzee Avatar asked Oct 18 '22 18:10

LetsPlayYahtzee


1 Answers

check on your filesystem for a file named libsqlncli*. If you'll find it check:

  • permissions
  • rows reporting "NOT FOUND" in the output of the ldd command executed against this file;
  • If all seems to be ok check for/ddd the following entry in your odncinst.ini file:

    [SQL Server Native Client 1[0|1].0] Description=Microsoft SQL Server ODBC Driver V1.0 for Linux Driver=/opt/microsoft/sqlncli/lib64/libsqlncli-11.0.so.1790.0 UsageCount=1

like image 100
Giova Avatar answered Oct 21 '22 06:10

Giova