How to automate ODBC DSN creation on Mac OS
Ok, I searched and searched and searched for this. Found a lot of stuff about Windows but NOTHING about how to automate ODBC DSN creation on a Mac. On Tiger, this is very, very easy.
Basically, you have to add the appropriate config lines to the file found in /Library/ODBC/odbc.ini
For example, let’s say you have a sqlite database that you want to connect to. You have installed the Actual Technology ODBC drivers but you want to deploy this application to a bunch of machines. You don’t have apple remote desktop, and you just want to run a script to get the job done.
The file is a standard ini file. You have to modify one category and add one in order to install the DSN. You must add the name of the new category (which is also the name of the DSN) to the ODBC Data Sources section. In this example, you would add a line like this:
newtest = Actual Open Source Databases
Now, you add a new section to the ini file that looks something like this
[newtest]
Driver = /Library/ODBC/Actual Open Source Databases.bundle/Contents/MacOS/atopnsrc.so
Type = SQLite
DBQ = /Users/jsmith/Documents/sqlite/test.db
Now, if you fire up the ODBC administrator, you will see your new DSN. Now for the Great Part: If you add this stuff to the /Library/ODBC/odbc.ini you create a system DSN. If, however, you add it to the odbc.ini found in ~/Library/ODBC (your home directory) you create a USER dsn.
Pretty cool, huh?

