schemadiff.py
changeset 5 57cf8fdff5ed
parent 2 efee419b7a2d
child 7 685b20d2d3ab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schemadiff.py	Wed Jul 20 10:54:07 2011 +0200
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3.2
+
+from pgtools import pgmanager, pgbrowser, pgdiff
+from toolbase import SrcDstTool
+
+
+class SchemaDiffTool(SrcDstTool):
+    def __init__(self):
+        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()