Welcome to the django-pyodbc wiki!
Download freetds linux packages for ALTLinux, Arch Linux, CentOS, Fedora, FreeBSD, Mageia, OpenMandriva, openSUSE, PCLinuxOS, ROSA, Slackware. FreeTDS is an extremely well-documented project, so be sure and take advantage of the User Guide, which has a wealth of information about using FreeTDS in various programming languages, troubleshooting, advanced configuration, and more.
Below are instructions for setting up a Mac to connect to a MS SQL Server database.
Unix For Mac Os X
Summary
I'm using a Mac on Yosemite Version 10.10.1 trying to connect to a MS SQL Server database. I searched and couldn't find an updated detailed answer so here's a writeup that is mostly from this amazing article here. I'm adding it on stackoverflow in case the link dies. The idea is that we'll have the following layers to setup/connect.
Layers
- PART 1 - pyodbc
- PART 2 - freeTDS (can check with tsql)
- PART 3 - unixODBC (can check with isql)
- PART 4 - MS SQL (can check with a regular python program)
Steps
Install Homebrew from here - this is a package manager for Mac OSX. The article shows how to use another package manager 'MacPorts'. For my instructions, they're with homebrew. Basically homebrew has a folder 'cellar' that holds different versions of packages. Instead of modifying your normal files, it instead points to these homebrew packages.
We need to install Pyodbc:
Install FreeTDS with
brew install freetds --with-unixodbc
(FreeTDS is the driver that sits between the Mac ODBC and MS SQL Server, this chart here shows which version of TDS you should be using based on your specific Microsoft Server version; e.g. tds protocol 7.2 for Microsoft SQL Server 2008).Configure
freetds.conf
file (The file should be in '/usr/local/etc/freetds.conf', which for Homebrew is a link to say '/usr/local/Cellar/freetds/0.91_2/etc', but yours might be somewhere different depending on version). I edited the global and added my database info to the end (for some reason 'tds version = 7.2' would throw an error, but still work, while 8.0 just works):Verify FreeTDS installed correctly with:
tsql -S myserver -U myuser -P mypassword
(you should see a prompt like this if it worked)Install unixODBC with
brew install unixodbc
.Setup your unixODBC config files, which includes odbcinst.ini (driver configuration), and odbc.ini (DSN configuration file). By default, my files were in:
/Library/ODBC
(Note: NOT my user library aka /Users/williamliu/Library). Or they could also be in your homebrew installation directory/usr/local/Cellar/unixodbc/<version>/etc
.Open up your 'odbcinst.ini' file and then add the following (Note: Different if you use MacPorts. For Homebrew, this file is a link to the homebrew version e.g. mine is in '/usr/local/Cellar/freetds/0.91_2/lib/libtdsodbc.so'):
Open up your 'odbc.ini' and then add the following (this is usually along with
odbcinst.ini
:Verify unixODBC installed correctly with:
isql MYSERVER MYUSER MYPASSWORD
. If you get an error that you cannot connect, then add-v
to check what the verbose output is and fix it. Otherwise, you should see this:Now verify pyodbc works with a python program. Run python in the shell or a .py file with this and you should get your query back:
You can refer to the documentation of pyodbc to get more help after this.
Welcome to the django-pyodbc wiki!
Below are instructions for setting up a Mac to connect to a MS SQL Server database.
Summary
I'm using a Mac on Yosemite Version 10.10.1 trying to connect to a MS SQL Server database. I searched and couldn't find an updated detailed answer so here's a writeup that is mostly from this amazing article here. I'm adding it on stackoverflow in case the link dies. The idea is that we'll have the following layers to setup/connect.
Layers
- PART 1 - pyodbc
- PART 2 - freeTDS (can check with tsql)
- PART 3 - unixODBC (can check with isql)
- PART 4 - MS SQL (can check with a regular python program)
Download Unix For Mac
Steps
Unix
Install Homebrew from here - this is a package manager for Mac OSX. The article shows how to use another package manager 'MacPorts'. For my instructions, they're with homebrew. Basically homebrew has a folder 'cellar' that holds different versions of packages. Instead of modifying your normal files, it instead points to these homebrew packages.
We need to install Pyodbc:
Install FreeTDS with
brew install freetds --with-unixodbc
(FreeTDS is the driver that sits between the Mac ODBC and MS SQL Server, this chart here shows which version of TDS you should be using based on your specific Microsoft Server version; e.g. tds protocol 7.2 for Microsoft SQL Server 2008).Configure
freetds.conf
file (The file should be in '/usr/local/etc/freetds.conf', which for Homebrew is a link to say '/usr/local/Cellar/freetds/0.91_2/etc', but yours might be somewhere different depending on version). I edited the global and added my database info to the end (for some reason 'tds version = 7.2' would throw an error, but still work, while 8.0 just works):Verify FreeTDS installed correctly with:
tsql -S myserver -U myuser -P mypassword
(you should see a prompt like this if it worked)Install unixODBC with
brew install unixodbc
.Setup your unixODBC config files, which includes odbcinst.ini (driver configuration), and odbc.ini (DSN configuration file). By default, my files were in:
/Library/ODBC
(Note: NOT my user library aka /Users/williamliu/Library). Or they could also be in your homebrew installation directory/usr/local/Cellar/unixodbc/<version>/etc
.Open up your 'odbcinst.ini' file and then add the following (Note: Different if you use MacPorts. For Homebrew, this file is a link to the homebrew version e.g. mine is in '/usr/local/Cellar/freetds/0.91_2/lib/libtdsodbc.so'):
Open up your 'odbc.ini' and then add the following (this is usually along with
odbcinst.ini
:Verify unixODBC installed correctly with:
isql MYSERVER MYUSER MYPASSWORD
. If you get an error that you cannot connect, then add-v
to check what the verbose output is and fix it. Otherwise, you should see this:Now verify pyodbc works with a python program. Run python in the shell or a .py file with this and you should get your query back:
Freetds Download Unix For Mac Os X
You can refer to the documentation of pyodbc to get more help after this.