2
|
1 |
#!/usr/bin/env python3.2
|
|
2 |
|
|
3 |
from pgtools import pgmanager, pgbrowser, pgdiff
|
5
|
4 |
from toolbase import SrcDstTool
|
2
|
5 |
|
|
6 |
|
5
|
7 |
class SchemaDiffTool(SrcDstTool):
|
|
8 |
def __init__(self):
|
|
9 |
SrcDstTool.__init__(self, name='schemadiff', desc='Database schema diff.')
|
|
10 |
|
|
11 |
self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
|
|
12 |
self.parser.add_argument('-t', dest='table', nargs='*', help='Table filter')
|
|
13 |
|
|
14 |
self.init()
|
2
|
15 |
|
5
|
16 |
def main(self):
|
|
17 |
srcbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('src'))
|
|
18 |
dstbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('dst'))
|
2
|
19 |
|
5
|
20 |
pgd = pgdiff.PgDiff(srcbrowser, dstbrowser)
|
2
|
21 |
|
5
|
22 |
if self.args.schema:
|
|
23 |
pgd.filter_schemas(include=self.args.schema)
|
|
24 |
|
|
25 |
if self.args.table:
|
|
26 |
pgd.filter_tables(include=self.args.table)
|
2
|
27 |
|
5
|
28 |
pgd.print_diff()
|
|
29 |
|
2
|
30 |
|
5
|
31 |
tool = SchemaDiffTool()
|
|
32 |
tool.main()
|