platiumky / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Make connection properties sent to the server easily accesible from API #93

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Fresh install of pymssql from repo
2. Attempt to connect to a Sybase db with pymssql.connect(...)

What is the expected output? What do you see instead?
Expect a database connection to be returned. Instead a MSSQLDriverException is 
thrown: "Could not set connection properties"

What version of the product are you using? On what operating system?
pymssql-HEAD, freetds 0.82-7 on 64-bit Linux 3.0.0 (Ubuntu)

Please provide any additional information below.
Some of the SET commands appearing in _mssql.pyx:507 to set some connection 
properties are unsupported on our Sybase database, causing the connection to 
fail. 

Connecting to the database via tsql works just fine. The debug log generated by 
freetds shows the SET statements failing. If I comment out the section of code 
which sets the properties and rebuild, I am able to establish a functional 
connection to the database.

My suggestion is to move the connection properties -- which is just a list of 
SQL statements -- into the library API so that end-users can modify the list of 
statements which get executed right after the connection comes up. It would 
allow me to work around the Sybase problem by simply setting 
pymssql.connection_properties = []. For others, it would allow them to change 
at run-time something which used to be a compile time parameter.

I have attached a patch that I have working in my environment, I hope this can 
be of some use.

Original issue reported on code.google.com by mas...@gmail.com on 29 Jun 2012 at 8:43

Attachments:

GoogleCodeExporter commented 8 years ago
For good measure, this is tested on Python 2.7.2

Original comment by mas...@gmail.com on 29 Jun 2012 at 8:50

GoogleCodeExporter commented 8 years ago
Randy, did pymssql ever claim to support Sybase? If not, should we close this?

Original comment by msabr...@gmail.com on 13 Feb 2013 at 3:44

GoogleCodeExporter commented 8 years ago
> Randy, did pymssql ever claim to support Sybase? If not, should we close this?

No, we haven't claimed to that I know of.  However, FreeTDS supports it so I 
think we should too (since it shouldn't really be more difficult).  The OP has 
a good point about the API regardless, those initial connection properties 
should be moved out into API land so the developer using pymssql can manipulate 
them.

Original comment by randy.sy...@lev12.com on 18 Feb 2013 at 4:20

GoogleCodeExporter commented 8 years ago

Original comment by rsyr...@gmail.com on 18 Feb 2013 at 5:52

GoogleCodeExporter commented 8 years ago

Original comment by rsyr...@gmail.com on 18 Feb 2013 at 5:52

GoogleCodeExporter commented 8 years ago
How to install this patch?

Original comment by alfonsoj...@gmail.com on 14 Jun 2013 at 12:56