schemadiff.py
changeset 16 cb7e13711a99
parent 9 2fcc8ef0b97d
child 44 4fe39c59c515
equal deleted inserted replaced
15:93450b43e627 16:cb7e13711a99
     7     def __init__(self):
     7     def __init__(self):
     8         toolbase.SrcDstTool.__init__(self, name='schemadiff', desc='Database schema diff.')
     8         toolbase.SrcDstTool.__init__(self, name='schemadiff', desc='Database schema diff.')
     9         
     9         
    10         self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
    10         self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
    11         self.parser.add_argument('-t', dest='table', nargs='*', help='Table filter')
    11         self.parser.add_argument('-t', dest='table', nargs='*', help='Table filter')
       
    12         self.parser.add_argument('--sql', action='store_true', help='Output is SQL script.')
    12         
    13         
    13         self.init()
    14         self.init()
    14 
    15 
    15     def main(self):
    16     def main(self):
    16         srcbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('src'))
    17         srcbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('src'))
    22             pgd.filter_schemas(include=self.args.schema)
    23             pgd.filter_schemas(include=self.args.schema)
    23         
    24         
    24         if self.args.table:
    25         if self.args.table:
    25             pgd.filter_tables(include=self.args.table)
    26             pgd.filter_tables(include=self.args.table)
    26 
    27 
    27         pgd.print_diff()
    28         if self.args.sql:
       
    29             pgd.print_patch()
       
    30         else:
       
    31             pgd.print_diff()
    28 
    32 
    29 
    33 
    30 tool = SchemaDiffTool()
    34 tool = SchemaDiffTool()
    31 tool.main()
    35 tool.main()