10
|
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()
|