- #UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE INSTALL#
- #UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE DRIVER#
- #UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE WINDOWS#
$query of course being replace by an sql statement such as “ select * from user” and $dsn is the name of the heading in your odbc.ini file. Go ahead and try executing isql from the command line now
#UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE DRIVER#
Port defaults to 3306 (for MySQL) and I don’t Know what Option 3 does (MySQL 3.x?) The driver should be the same as the heading name specified in /etc/odbcinst.ini. Now you should be good to go, provided you have the right server/user/password/database/port. (Ubuntu provides another example at /usr/share/doc/libmyodbc/examples/odbc.ini) Copy this to either your global /etc/odbc.ini or create one specific to your user at ~/.odbc.ini Now you can create a DSN that references your driver. The trick is to find where your driver and setup files are ( libmyodbc.so and libodbcmyS.so) and point to them in /etc/odbcinst.ini USER DATA SOURCES.: /home/aaron/.odbc.iniĭrivers need to be installed by root (or someone with permissions to edit /etc/odbcinst.ini.) An example driver (on my Ubuntu system is available at /usr/share/libmyodbc/odbcinst.ini) and looks like this: Now run the command ‘ odbcinst -j‘ to see where it looks for configuration files. On Redhat-based systems (including Fedora and Centos) On Debian-based systems (including Ubuntu)
#UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE INSTALL#
It’s not identical to the old command line tool, which my faulty memory tells me could spit out raw results (while walking uphill in the snow), but it’s fairly customizable, and with a little bit of help from standard tools like grep and sed, can give me what I want.įirst, install unixodbc and the appropriate driver (e.g.
#UNIXODBC ISQL BATCH SCRIPT EXAMPLE FOR SYBASE WINDOWS#
ODBC is, of course, Microsoft’s database connection standardization, and probably one of the main reasons they won the enterprise application development wars (the other reason obviously being that users were familiar with Windows UI.) This stems from Microsoft SQL Server’s heritage from Sybase which included a port of isql. I did a search on “isql” and it turns out that unixodbc has a tool with just that name. You could use your favorite scripting language to build queries, or even a generic query tool, but that’s not really portable. Most importantly, they don’t work with standard input and standard output. They’re text-based shells that establish a persistent connection to the database and have their own commands. They both have “command line clients” but they’re not really command line tools. Sadly, neither MySQL or PostgreSQL seem to have this feature. There may have been something like this for Oracle as well, but I doubt it. It was great for ad hoc queries, shell scripts, batch processes, and cron jobs. I seem to remember a tool called “isql” for informix that worked like this.
It should be able to specify which database you want to connect to (or optionally configure a default.) It should accept a query via STDIN (or as an argument) and return the result to STDOUT (or to a file). I want to run a query against the database from the command line.