comparison lemuriformes/count.py @ 10:ad1bf59eedb0

[SQL] add count CLI front-end
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 13:57:33 -0800
parents
children
comparison
equal deleted inserted replaced
9:b69efcf85807 10:ad1bf59eedb0
1 #!/usr/bin/env python
2
3 """
4 list SQL table counts
5 """
6
7 import sys
8 from .cli import ConfigurationParser
9 from .url2sql import url2sql
10
11
12 def main(args=sys.argv[1:]):
13 """CLI"""
14
15 # parse command line
16 parser = ConfigurationParser(description=__doc__)
17 parser.add_argument('connection',
18 type=url2sql,
19 help="URL of SQL connection")
20 options = parser.parse_args(args)
21
22 # display table counts
23 connection = options.connection
24 tables = connection.tables()
25 for table in tables:
26 count = connection.count(table)
27 print ("{},{}".format(table, count))
28
29
30 if __name__ == '__main__':
31 main()