在Ubuntu上通过pyODBC连接到Microsoft SQL Server [英] Connecting to Microsoft SQL Server through pyODBC on Ubuntu

查看:66
本文介绍了在Ubuntu上通过pyODBC连接到Microsoft SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ubuntu(12.10)计算机上从 pyODBC 连接到Microsoft SQL Server实例时遇到问题.

Am having an issue connecting to a Microsoft SQL Server instance from pyODBC within an Ubuntu (12.10) machine.

我回来的错误是:

pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data Source name not found, and no default driver specified (0) (SQLDriverConnect)')

用于 pyodbc 的连接字符串是:

The connection string am using for pyodbc is:

self.corpus_cnxn = pyodbc.connect('DRIVER={FreeTDS};SERVER=UKEDN-06880;DATABASE=db1;UID=user;PWD=pass')

这似乎可以从Windows中的pyODBC正常工作(只需要将DRIVER更改为"SQL Server"而不是"FreeTDS"),当我尝试使用 tsql从Ubuntu计算机连接时,它工作正常从终端上使用以下命令工具:

This seems to work fine from pyODBC within Windows (just need to change the DRIVER to 'SQL Server' instead of 'FreeTDS'), and it work fine when I try to connect from the Ubuntu machine using the tsql Tool from the terminal, with the following command:

tsql -S UKEDN-06880 -p 1433 -U user -P pass

我可以选择没有问题的任何表,但是在pyODBC中似乎不起作用.

I can select any table with no issues, it just doesn't seem to work from within pyODBC.

任何帮助或建议都将不胜感激,尽管我的Linux技能在tsql中起作用,但我的Linux技能却非常薄弱,完全陷入困境!

Any help or advice will be much appreciated, my Linux skills are uber weak and am totally stuck, although since it works from tsql I get the feeling that am very close!

推荐答案

由于您可以使用tsql,因此您似乎已经获得了freeTDS的正常运行.您是否尝试过与 isql 连接?

It looks like you have gotten freeTDS to work correctly since you can use tsql. Have you tried to connect with isql?

请参见 howto 详细了解.我认为您需要的部分是在页面下方进行一些设置unixodbc的操作.

Look at this howto for a detailed walk through. The part I think you need is in setting up unixodbc a little ways down the page.

这篇关于在Ubuntu上通过pyODBC连接到Microsoft SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆