Skip to content
tlanclos edited this page Nov 13, 2015 · 2 revisions

unixODBC Setup Help Page

Background

The database connection to the Techneaux ticket database is handled and configured through an implementation of ODBC known as unixODBC. In order to connect to the ticket database, we chose FreeTDS which is a set of libraries used to interface with SQL Server databases. There is also one last piece to this puzzle. FreeTDS and unixODBC are disjoin; there is no initial relation between the two libraries. So, in order to interface with FreeTDS via unixODBC, we used freetdsodbc which is an adapter (driver) that allows unixODBC to communicate with FreeTDS.

Caveats

It is unfortunate that the driver file provided by freetdsodbc is non-executable because unixODBC requires this file to have executable permissions. In order to fix this problem, simply chmod the appropriate library file (libtdsodbc.so).

Configuration

There exist two files that allow connection to happen. The first file is /etc/odbcinst.ini and the second /etc/odbc.ini. Here I will show the files and then give a brief description of each line. It is important to know that these files have many more options, but I will only explain the essential configuration rules to get the ticket-api up and running.

/etc/odbcinst.ini

This file specifies specific driver configurations for unixODBC, in here we specify one driver for FreeTDS called FreeTDS. Please read config/build.md for more information on finding the file locations for Driver and Setup.

[FreeTDS]
Driver     = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup      = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Threading  = 1

[FreeTDS] - This line specifies the driver name for unixODBC
Driver = ... - ODBC driver library location
Setup = ... - ODBC setup library location
Threading = - This is not currently necessary, but it tells ODBC to run this driver in a thread as to not serialize all SQL calls through ODBC

/etc/odbc.ini

This file specifies an actual set of DSN connections. Here you can fully specify a connection DSN, but we will only specify information to connect to the database and the correct TDS version to use. We will not specify the database username and password. I have intentionally left out the actual Techneaux database name and server for privacy concerns. Instead I will explain the parameters and leave it up to the developer to include the information.

[TechneauxTicketDB]
Driver          = FreeTDS
Server          = place.server.name.here
Database        = DatabaseName
Port            = 1433
TDS_Version     = 7.1

[TechneauxTicketDB] - This is the DSN name that may be used with an odbc connection string to connect to this database
Driver = ... - This is the driver we specified in the file listed above /etc/odbcinst.ini
Server = ... - Database server name, no database name should be specified
Database = ... - Database name, this should contain only the name of the database
Port = ... - Port used to connect to the database (which port is the database running on)
TDS_Version = 7.1 - Keep this at TDS version 7.1, but it will specify the TDS version to use for FreeTDS. Unfortunately, this cannot be placed in the former file under the driver specification

Clone this wiki locally