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.
|
NOTE: This tool has been replaced by SQLShell. sqlcmd is no longer being actively maintained, though I may apply bug fixes now and then.
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:
- Unpack the tarball or Zip file.
- Change your directory to the resulting sqlcmd-0.7 directory.
- 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
Testimonials
I was hacking away on [a] small consulting project. I was trying to move very quickly, and having problems getting Ruby to play with Postgres. The only thing working fine was SQLite, but I was on some incredibly screwy machine that wouldn't load the prompt, so I couldn't verify any of the data.
+1 sqlcmd — Field tested and verified ass-saver.
— Mark Chadwick
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 $
|