ODBC Shell

ODBC Shell is a command line ODBC client for Unix environments. The goal of ODBC Shell is to provide an easy and polished utility for accessing databases from the commandline.

Features

  • Ability to maintain multiple concurrent database connections.
  • Command history using GNU Readline.
  • Output results as CSV, Fixed Length Fields, SQL, or XML.
  • Licensed under the Bindle Binaries Open Source license.

Software Requirements

  • GNU Autoconf 2.65
  • GNU Automake 1.10
  • GNU GCC 4.2.1
  • GNU Libtool 2.4
  • GNU Readline 6.1
  • iODBC 3.52.6 or unixODBC 2.3.0
  • Git 1.7

Tested Platforms

FreeBSD 8.1

  • MyODBC 3.51.26
  • SQLite ODBC 0.88
OS X 10.6.6
  • FileMaker xDBC 11.3.76
  • MyODBC 5.1.8
  • SQLite ODBC 0.88
Slackware 13.1
  • MyODBC 5.1.8
  • SQLite ODBC 0.88

Source Code

The current pre-release of ODBC Shell is 0.0.223.g8c55b2b.

Older versions are available on the Bindle Binaries' download server.

The source code for ODBC Shell is maintained using git (http://git-scm.com). The latest development source code may be checked out using the following commands:

$ git clone git://github.com/bindle/odbcshell.git
$ cd odbcshell
$ autoreconf -i -f -I m4

The current development source code may be viewed at the following URLs:

Examples

  1. Using ODBC Shell help.
  2. Connecting to a database.
  3. Using multiple databases.
  4. Listing driver versions.
  5. Disconnecting from databases.
  6. Connect using driver without DSN.

Displaying list of supported commands:

$ odbcshell
Welcome to ODBC Shell v0.0.164.g78c9418.

Type "help" for usage information.

odbcshell> help
This is odbcshell version 0.0.119.g6369498
Topics:
   CLEAR      CONNECT    DISCONNECT DSN        ECHO        
   EXIT       HELP       LOGOUT     QUIT       RECONNECT   
   RESETCONF  SET        UNSET      USE        VERSION     
For more info use "HELP ;".
End of HELP info.
odbcshell> help connect
CONNECT Command:
Description:
       connects to a database
Usage:
       CONNECT "DSN=My Database;UID=jdoe;PWD=pass";
       CONNECT name "DSN=My Database;UID=jdoe;PWD=pass";
End of HELP info.
odbcshell> quit
bye.
$ 
				

Connecting to database and performing query:

odbcshell> connect "DSN=Library;UID=jdoe;PWD=pass"
using connection "default"
odbcshell> select Item, Description from Assets
"Item","Description"
"OpenSSL","O'Reilly Tech Book"
"Learning SQL","O'Rielly Tech Book"
"Test Book","A book of tests."

result set 1 returned 3 rows.

odbcshell> disconnect
				

Connecting to multiple databases:

odbcshell> connect library "DSN=Library;UID=jdoe;PWD=pass"
using connection "library"
odbcshell> connect tickets "DSN=Redmine;UID=jdoe;PWD=pass"
using connection "tickets"
odbcshell> connect blog "DSN=BLOGS;UID=jdoe;PWD=pass"
using connection "blog"
odbcshell> connect wiki "DSN=MediaWiki;UID=jdoe;PWD=pass"
using connection "wiki"
odbcshell> use
  Name:      DSN:
  library    DSN=Library;UID=jdoe;PWD=pass
  tickets    DSN=Redmine;UID=jdoe;PWD=pass
  blog       DSN=BLOGS;UID=jdoe;PWD=pass
* wiki       DSN=MediaWiki;UID=jdoe;PWD=pass
odbcshell> use tickets
using connection "tickets"
odbcshell> use
  Name:      DSN:
  library    DSN=Library;UID=jdoe;PWD=pass
* tickets    DSN=Redmine;UID=jdoe;PWD=pass
  blog       DSN=BLOGS;UID=jdoe;PWD=pass
  wiki       DSN=MediaWiki;UID=jdoe;PWD=pass
odbcshell>
			

Listing version of ODBC Shell, Device Manager, and Device drivers:

odbcshell> version
odbcshell (ODBC Shell) 0.0.119.g6369498
iODBC Driver Manager 03.52.0607.1008
connection: library (fmodbc.so) 11.3.76
connection: tickets (libmyodbc5.so) 05.01.0008
connection: blog (libmyodbc5.so) 05.01.0008
connection: wiki (sqlite3odbc.so) 0.88
odbcshell>
				

Diconnecting from multiple databases:

odbcshell> use
  Name:      DSN:
  library    DSN=Library;UID=jdoe;PWD=pass
* tickets    DSN=Redmine;UID=jdoe;PWD=pass
  blog       DSN=BLOGS;UID=jdoe;PWD=pass
  wiki       DSN=MediaWiki;UID=jdoe;PWD=pass
odbcshell> disconnect blog
odbcshell> disconnect library
odbcshell> use
  Name:      DSN:
* tickets    DSN=Redmine;UID=jdoe;PWD=pass
  wiki       DSN=MediaWiki;UID=jdoe;PWD=pass
odbcshell> disconnect
using connection "wiki"
odbcshell> use
  Name:      DSN:
* wiki       DSN=MediaWiki;UID=jdoe;PWD=pass
odbcshell> disconnect
odbcshell> use
  Name:      DSN:
odbcshell>
				

Connect using driver:

odbcshell> connect 'Driver=/usr/local/lib/libmyodbc5.so;
> SETUP=/usr/local/lib/libmyodbc3S.so;
> database=redmine;
> server=127.0.0.1;port=3306;
> user=jdoe;password=drowssap'
using connection "default"
odbcshell> version
odbcshell (ODBC Shell) 0.0.164.g78c9418
iODBC Driver Manager 03.52.0607.1008
connection: default (libmyodbc5.so) 05.01.0008
odbcshell>