ToolBase: add -d parameter, which triggers debug mode (print SQL queries).
#!/usr/bin/env python3.2
#
# Print differencies between data in two tables of same schema.
#
# Requirements:
# * First column of both tables must be numerical primary key.
# * Destination table must contain all columns from source table.
# Order is not important.
#
from pgtoolkit import pgmanager, pgbrowser, pgdatadiff, toolbase
class TableDiffTool(toolbase.SrcDstTool):
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('--sql', action='store_true', help='Output is SQL script.')
self.init()
def main(self):
table = self.args.table
schema = self.args.schema
dd = pgdatadiff.PgDataDiff(self.pgm.get_conn('src'), self.pgm.get_conn('dst'))
dd.settable1(table, schema)
dd.settable2(table, schema)
if self.args.sql:
dd.print_patch()
else:
dd.print_diff()
tool = TableDiffTool()
tool.main()