view lemuriformes/count.py @ 18:56596902e9ae default tip

add some setup + tests
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:57:03 -0800
parents ad1bf59eedb0
children
line wrap: on
line source

#!/usr/bin/env python

"""
list SQL table counts
"""

import sys
from .cli import ConfigurationParser
from .url2sql import url2sql


def main(args=sys.argv[1:]):
    """CLI"""

    # parse command line
    parser = ConfigurationParser(description=__doc__)
    parser.add_argument('connection',
                        type=url2sql,
                        help="URL of SQL connection")
    options = parser.parse_args(args)

    # display table counts
    connection = options.connection
    tables = connection.tables()
    for table in tables:
        count = connection.count(table)
        print ("{},{}".format(table, count))


if __name__ == '__main__':
    main()