views:

64

answers:

1

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
+1  A: 

According to MSDN you should be able to set these in the connection string:

cnxn = pyodbc.connect("DSN=someDSN;UID=someUser;PWD=somePass;QuotedID=Yes;AnsiNPW=Yes")
Mark
For some reason, setting this in the connection string didn't work, but adding those settings to my odbc.ini file worked.
Brendan Long