Introduction Overview Documentation Summary Sourceforge Download

ShellSQL - SQL for Shell Scripts

ShellSQL is a suite of programs designed to enable LINUX/UNIX shell scripts to connect to SQL engines and execute SQL queries and commands in a simple way enabling intergration with the rest of the script. For example, it can do things like..

HANDLE=`shpostgres dbname=mydb`

shsql $HANDLE "begin"

for ARG in $*

        shsql $HANDLE "insert into mytable (fld1, fld2)" \
                       "values (nextval('myseq'), '$ARG')"


shsql $HANDLE "commit"

if [ $# -gt 0 ]

        ROWS=`shsql $HANDLE "select count(*) from mytable"`

        echo "No of rows now in table is" $ROWS


shsqlend $HANDLE

For details on how it hangs together have a look at the overview.

The following database engines are supported...
  1. PostgreSQL
  2. MySQL
  3. SQLite3 and SQLite version 2
  4. Unix ODBC
  5. FreeTDS
More may well be added if people request them.

The software can be downloaded from here. There is also some detailed documentation as well as a brief usage summary of the commands.

The programs sares released under the GNU Public License.

If you have problems, or find bugs, please email me on, if there is sufficient interest I will start a mailing list.


Version History

Version 0.7.7 - 27-February-07 - Removed .o files from distribution (oops! :-( )
Version 0.7.6 - 26-August-05 - Fixed username/password wipe bug in shodbc
              - fix submitted by Walter Haslbeck (haslbeck AT t-online DOT de)
Version 0.7.5 - 14-July-05 - SQLite (version 2) added
Version 0.7.4 - 12-July-05 - Updates doc to include "eval" in "eval set $ROWS"
Version 0.7.3 - 10-June-05 - Included code to try and close shsql cleanly
version 0.7.3 - 7-May-05 - Bug fix in sarg.c and shsqlinp.c and
version 0.7.2 - 7-May-05 - Bug fix in shsql
Version 0.7.1 - 31-January-05 - Bug fix release in shmysql
Version 0.7 - 30-January-05 - Included following:
	    - Addition of freetds engine for MS-SQL and Sybase
	    - included of --csv, --pipe, --colon, --tab and --shell output
	      formatting commands to shsql
	    - Added shsqlinp routine
	    - General bug fixes/tidy ups
Version 0.6 - 10-November-04 - General tidy up of code
Version 0.5 - 6-November-04 - Repackaged tar file
Version 0.4 - 5-November-04 - Fixed message.h
Version 0.3 - 5-November-04 - Corrected documentation errors
Version 0.2 - 4-November-04 - First published Logo