view lemuriformes/count.py @ 16:9b1bb9eee962

misc functions related to filesystem paths
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:19:30 -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()