Reputation: 7347
I've followed all the steps from this link: https://code.google.com/p/pypyodbc/wiki/Linux_ODBC_in_3_steps
But I'm still getting this error:
[unixODBC][Driver Manager] Data source name not found, and no default driver specified
Then when I started researching more, I found this: https://askubuntu.com/questions/167491/connecting-ms-sql-using-freetds-and-unixodbc-isql-no-default-driver-specified
Now it says to modify odbc.ini file to include the server and database name. But if I'm trying to connect to multiple servers at the same time, how should I configure odbc.ini file in this case?
Also - in my database connection string, should I enter the driver name as {SQL Server} or {FreeTDS}?
Upvotes: 2
Views: 2898
Reputation: 14361
Here's an example set up with FreeTDS, unixODBC, and friends:
freetds.conf:
[server1]
host = one.server.com
port = 1433
tds version = 7.3
[server2]
host = two.server.com
port = 1433
tds version = 7.3
odbc.ini:
[server1]
Driver = FreeTDS
Server = one.server.com
Port = 1433
TDS_Version = 7.3
[server2]
Driver = FreeTDS
Server = two.server.com
Port = 1433
TDS_Version = 7.3
odbcinst.ini:
[FreeTDS]
Description = FreeTDS with Protocol up to 7.3
Driver = /usr/lib64/libtdsodbc.so.0
The Driver =
location may differ above, depending on your distro of FreeTDS.
pyodbc connect, DSN free:
DRIVER={FreeTDS};SERVER=one.server.com;PORT=1433;DATABASE=dbname;UID=dbuser;PWD=dbpassword;TDS_Version=7.3;
A few notes:
See here for more:
https://msdn.microsoft.com/en-us/library/dd339982.aspx
Good luck.
Upvotes: 3
Reputation: 123839
if I'm trying to connect to multiple servers at the same time, how should I configure odbc.ini file in this case?
If you want to connect to more than one server you will need to create a separate DSN entry for each one and use more than one pyodbc connection
object. Either that, or set up a "Linked Server" on one of the SQL Server instances so you can access both through the same pyodbc connection.
in my database connection string, should I enter the driver name as {SQL Server} or {FreeTDS}?
If you are editing "odbc.ini" then you are creating DSN entries. You would use the DSN name in your connection string, and pyodbc would get the details (server name, database name) from the corresponding entry in "odbc.ini".
Upvotes: 0