[logo] sqlcmd: A Cross-platform, Cross-database SQL Command Line Tool

Download

To obtain my PGP/GnuPG key, see these instructions.

Documentation

Similar Projects

  • SQLPython, a very comprehensive Python-based alternative to Oracle's SQL*Plus. Oracle-specific.
  • PySQL, another Oracle-specific Python-based command-line SQL tool.
  • dbishell, a similar Perl-based tool

Back to software page.

sqlcmd is a Python-based SQL command line tool, similar in concept to tools like Oracle's SQL*Plus, the PostgreSQL psql command, and MySQL's mysql tool.

Some Features at a Glance

  • Connection parameters for individual databases are kept in a configuration file in your home directory.
  • Databases can be assigned multiple logical names.
  • Command history management, with GNU Readline support. Each database has its own history file.
  • Supports retrieving database metadata (getting a list of tables, querying the table's columns and their data types, listing the indexes and foreign keys for a table, etc.).
  • Supports Unix shell-style variables.
  • Standard interface that works the same no matter what database you're using.
  • Uses the enhanced database drivers in the Grizzled API's db module. (Those drivers are, in turn, built on top of standard Python DB API drivers like psycopg2 and MySQLdb.)
  • Supports:
    • MySQL (tested with MySQL 5 on Linux, Mac OS X, and FreeBSD)
    • Oracle (tested with Oracle Database 10g Express Edition for Linux)
    • PostgreSQL (tested with versions 8.1 through 8.3 on Linux and Mac OS X)
    • SQL Server (tested with SQL Server Express 2005, using pymssql)
    • SQLite (tested on Linux and Mac OS X)
    You will have to install Python DB API drivers for all but SQLite.
  • Written entirely in Python, which makes it very portable (though the database drivers are often written in C and may not be available on all platforms).
In short, sqlcmd is a SQL command tool that attempts to provide the same interface for all supported databases and across all platforms.

sqlcmd has been tested on the following platforms:

  • Mac OS X, version 10.4 (Tiger), using MacPython
  • Linux (Ubuntu, Gutsy and Hardy)
  • FreeBSD
  • Windows XP, using the non-Cygwin Windows version of Python and pyreadline

Installation

The usual:

  1. Unpack the tarball or Zip file.
  2. Change your directory to the resulting sqlcmd-0.5 directory.
  3. Run: python setup.py install
This library is also available on PyPI. If you have Easy Install installed, you can install this package with one command (usually as root):
easy_install sqlcmd
To upgrade a previous version of sqlcmd that was installed via easy_install, use this command:
easy_install -U sqlcmd

Prerequisites

sqlcmd requires the following:

  • Python 2.5 or better
  • The Grizzled API (automatically installed if you use easy_install to install sqlcmd)
  • The enum module (automatically installed if you use easy_install)
  • Appropriate Python DB API drivers for the databases you want to use. See the User's Guide for details.
  • Windows only: You'll also want the ipython pyreadline package, available via easy_install or from http://ipython.scipy.org/dist/

Using sqlcmd

Please see the User's Guide.

Source Code Repository

The source code for sqlcmd is maintained on github. To clone the repository, run this command:

git clone git://github.com/bmc/sqlcmd.git

Author

Brian M. Clapper, <bmc @ clapper . org>

Copyright

© 2008 Brian M. Clapper

License

BSD-style license. See accompanying LICENSE file.

$Id: index.html,v 1.7 2005/05/20 14:37:58 bmc Exp $