tablediff.py
changeset 14 a900bc629ecc
parent 9 2fcc8ef0b97d
child 34 98c7809af415
--- a/tablediff.py	Fri Sep 09 11:56:37 2011 +0200
+++ b/tablediff.py	Thu Oct 20 13:54:35 2011 +0200
@@ -15,19 +15,28 @@
     def __init__(self):
         toolbase.SrcDstTool.__init__(self, name='tablediff', desc='Table diff.')
         
-        self.parser.add_argument('table', metavar='table', type=str, help='Table name')
-        self.parser.add_argument('-s', dest='schema', metavar='schema', type=str, default='public', help='Schema name.')
+        self.parser.add_argument('srctable', metavar='srctable',
+            type=str, help='Source table name.')
+        self.parser.add_argument('--dst-table', dest='dsttable', metavar='dsttable',
+            type=str, default=None, help='Destination table (default=srctable).')
+        self.parser.add_argument('-s', '--src-schema', dest='srcschema', metavar='srcschema',
+            type=str, default='public', help='Schema name (default=public).')
+        self.parser.add_argument('--dst-schema', dest='dstschema', metavar='dstschema',
+            type=str, default=None, help='Destination schema name (default=srcschema).')
         self.parser.add_argument('--sql', action='store_true', help='Output is SQL script.')
         
         self.init()
 
     def main(self):
-        table = self.args.table
-        schema = self.args.schema
-
+        srcschema = self.args.srcschema
+        dstschema = self.args.dstschema if self.args.dstschema else self.args.srcschema
+        
+        srctable = self.args.srctable
+        dsttable = self.args.dsttable if self.args.dsttable else self.args.srctable
+        
         dd = pgdatadiff.PgDataDiff(self.pgm.get_conn('src'), self.pgm.get_conn('dst'))
-        dd.settable1(table, schema)
-        dd.settable2(table, schema)
+        dd.settable1(srctable, srcschema)
+        dd.settable2(dsttable, dstschema)
         
         if self.args.sql:
             dd.print_patch()