# HG changeset patch # User Jeff Hammel # Date 1512943053 28800 # Node ID ad1bf59eedb0e452a2bcb85bd507a8a7e17906a9 # Parent b69efcf85807b1fd0cbb34286f1b27fe70f16b6a [SQL] add count CLI front-end diff -r b69efcf85807 -r ad1bf59eedb0 lemuriformes/count.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lemuriformes/count.py Sun Dec 10 13:57:33 2017 -0800 @@ -0,0 +1,31 @@ +#!/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()