bmc / sqlcmd

A Cross-platform, Cross-database SQL Command Line Tool

This URL has Read+Write access

sqlcmd / setup.py
100644 94 lines (81 sloc) 3.7 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
#
# EasyInstall setup script for paragrep
#
# $Id$
# ---------------------------------------------------------------------------
 
import ez_setup
ez_setup.use_setuptools(download_delay=2)
from setuptools import setup, find_packages
import re
import sys
import os
 
def loadInfo():
    # Look for identifiers beginning with "__" at the beginning of the line.
 
    result = {}
    pattern = re.compile(r'^(__\w+__)\s*=\s*[\'"]([^\'"]*)[\'"]')
    here = os.path.dirname(os.path.abspath(sys.argv[0]))
    for line in open(os.path.join(here, 'sqlcmd', '__init__.py'), 'r'):
        match = pattern.match(line)
        if match:
            result[match.group(1)] = match.group(2)
    return result
 
info = loadInfo()
 
LONG_DESCRIPTION = \
'''*sqlcmd* is a SQL command line tool, similar in concept to tools like Oracle's
`SQL*Plus`_, the PostgreSQL_ ``psql`` command, and MySQL_'s ``mysql`` tool.
 
.. _SQL*Plus: http://www.oracle.com/technology/docs/tech/sql_plus/index.html
.. _PostgreSQL: http://www.postgresql.org/
.. _MySQL: http://www.mysql.org/
 
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.
- *sqlcmd* has command history management, with `GNU Readline`_ support.
History files are saved per database.
- *sqlcmd* supports SQL, but also supports 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.).
- *sqlcmd* supports Unix shell-style variables.
- *sqlcmd* command has a ``.set`` command that displays and controls *sqlcmd*
settings.
- *sqlcmd* provides a standard interface that works the same no matter what
database you're using.
- *sqlcmd* 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``.)
- *sqlcmd* is 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).
 
.. _Grizzled API: http://www.clapper.org/software/python/grizzled/
.. _GNU Readline: http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html
.. _Python: http://www.python.org/
 
In short, *sqlcmd* is a SQL command tool that attempts to provide the same
interface for all supported databases and across all platforms.
'''
 
# Now the setup stuff.
 
setup(
    name = 'sqlcmd',
    version = info['__version__'],
    description = 'A cross-platform, cross-database SQL command line tool',
    long_description = LONG_DESCRIPTION,
    packages = find_packages(),
    py_modules = ['ez_setup'],
    url = info['__url__'],
    license = info['__license__'],
    author = info['__author__'],
    author_email = info['__email__'],
    entry_points = {'console_scripts' : 'sqlcmd=sqlcmd:main'},
    install_requires = ['grizzled>=0.9.2',
                        'enum>=0.4.3',],
    classifiers = ['Environment :: Console',
                        'Intended Audience :: Developers',
                        'Intended Audience :: System Administrators',
                        'Intended Audience :: Science/Research',
                        'License :: OSI Approved :: BSD License',
                        'Operating System :: OS Independent',
                        'Programming Language :: SQL',
                        'Topic :: Database :: Front-Ends',
                        'Topic :: Utilities'],
)