schemadiff.py
author Radek Brich <radek.brich@devl.cz>
Tue, 16 Aug 2011 23:53:54 +0200
changeset 10 f3a1b9792cc9
parent 9 2fcc8ef0b97d
child 16 cb7e13711a99
permissions -rwxr-xr-x
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.

#!/usr/bin/env python3.2

from pgtoolkit import pgmanager, pgbrowser, pgdiff, toolbase


class SchemaDiffTool(toolbase.SrcDstTool):
    def __init__(self):
        toolbase.SrcDstTool.__init__(self, name='schemadiff', desc='Database schema diff.')
        
        self.parser.add_argument('-s', dest='schema', nargs='*', help='Schema filter')
        self.parser.add_argument('-t', dest='table', nargs='*', help='Table filter')
        
        self.init()

    def main(self):
        srcbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('src'))
        dstbrowser = pgbrowser.PgBrowser(self.pgm.get_conn('dst'))
        
        pgd = pgdiff.PgDiff(srcbrowser, dstbrowser)

        if self.args.schema:
            pgd.filter_schemas(include=self.args.schema)
        
        if self.args.table:
            pgd.filter_tables(include=self.args.table)

        pgd.print_diff()


tool = SchemaDiffTool()
tool.main()