Hi Guys,
I have a python script running under Kubuntu accessing a SQL Server DB running on a Windows server. I use FreeTDS as the driver and it seems to work well.
FreeTDS.ini is not configured
But odbc.ini and odbcinst.ini both are AND I use a connection string. The issue is that the owner of the SQL server database says I am locking out other users.
After a bit of invetigation it appears there is a parameter in odbcinst.ini called Threading and the default in FreeTDS is Threading=3. Apparently this is exclusive locking and it is recommended that Threading=1 is used.
So now I belatedly realise that maybe I haven't understood the role of odbc.ini vs odbcinst.ini vs connection string and maybe I have some duplication. Ie I can't see any reference in my code to the odbc.ini, maybe it is all bypassed. Is that so? Here are the relevant parts of the files in question together with the connection string.
My question is, what is the recommended setup for the .ini files vs the connection string, and where should I put Threading =1.
odbc.ini
[<supplier>_dcn]
Driver = FreeTDS
Description = MSSQL database for my nice app
# Servername corresponds to the section in freetds.conf
Servername=192.168.0.2
Database = <name of database>
UID = <user ID>
PWD = <user password>
ReadOnly = No
Port = 1433
odbcinst.ini
# Define where to find the driver for the Free TDS connections.
[FreeTDS]
Description = MS SQL database access with Free TDS
Driver = /usr/local/lib/libtdsodbc.so
#Setup = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount = 2
Connection string
server = '192.168.0.2'
database = '<name of database>'
username = '<user ID>'
password = '<user password>'
driver= '{ODBC Driver 13 for SQL Server}'
try:
con=pyodbc.connect('DRIVER={FreeTDS};SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password+';TDS_VERSION=7.2')
except (pyodbc.Error, pyodbc.Warning) as e:
frame = inspect.currentframe()
Thanks for your help,
Steve