How to connect to windows SQL Server from Ubuntu

随声附和 提交于 2019-12-10 14:38:22

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/34747635/how-to-connect-to-windows-sql-server-from-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!