使用 Pyodbc + 设置连接设置UnixODBC +免费TDS
我有一个使用 Pyodbc、UnixODBC 和 FreeTDS 的设置,但其中某个地方正在设置一些选项,但我不知道在哪里。根据 SQL Server Management Studio,我的程序在打开连接时发送一些设置:
set quoted_identifier off
set ansi_padding off
set ansi_nulls off
...
但我需要一组不同的设置:
set quoted_identifier on
set ansi_padding on
set ansi_nulls on
...
有什么方法可以更改此设置吗?如果我无法使用当前的设置来完成此操作,是否可以在 Python 中使用任何其他库来更改它(最好使用 Python 数据库 API)?
更改数据库中的设置不是一个选项,因为我有很多其他项目使用我当前的设置。
已解决:
Mark 的答案是正确的,但我无法使其与 FreeTDS/UnixODBC 一起使用。将该信息添加到我的 odbc.ini 文件中效果很好:
[servername]
... other options ..
AnsiNPW = YES
QuotedID = YES
I have a setup using Pyodbc, UnixODBC and FreeTDS, but somewhere in there some options are being set and I don't know where. According to SQL Server Management Studio, my program is sending some settings when it opens the connection:
set quoted_identifier off
set ansi_padding off
set ansi_nulls off
...
But I need a different set of settings:
set quoted_identifier on
set ansi_padding on
set ansi_nulls on
...
Is there any way to change this? If I can't do it with my current setup, are there any other libraries I could use in Python that would let me change it (preferably using the Python Database API)?
Changing settings in the database isn't an option because I have a bunch of other projects that use my current settings.
Solved:
Mark's answer was correct, but I couldn't get it working with FreeTDS/UnixODBC. Adding that info to my odbc.ini file worked perfectly though:
[servername]
... other options ..
AnsiNPW = YES
QuotedID = YES
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 MSDN 您应该能够在连接字符串中设置这些:
According to MSDN you should be able to set these in the connection string: