from .cfg_app import PpCfgAppError, PpConfigApplication
-__version__ = '0.1.0'
+__version__ = '0.3.0'
LOG = logging.getLogger(__name__)
# =============================================================================
try:
self.get_src_info()
+ self.clean_tgt_db()
finally:
self._close_all()
print("Found tsigkeys: {:>8}".format(nr_tsigkeys))
print()
+ # -------------------------------------------------------------------------
+ def clean_tgt_db(self):
+
+ result = None
+
+ tables = [
+ 'comments', 'cryptokeys', 'domainmetadata', 'records',
+ 'supermasters', 'tsigkeys', 'domains',
+ ]
+
+ LOG.info("Truncating all tables in target database ...")
+
+ cur = self.tgt_connection.cursor()
+
+ try:
+
+ for table in tables:
+
+ LOG.debug("Truncating {!r} ...".format(table))
+ sql = 'TRUNCATE TABLE {} RESTART IDENTITY CASCADE'.format(table)
+ if self.verbose > 1:
+ LOG.debug("SQL: {}".format(sql))
+ cur.execute(sql)
+
+ LOG.debug("Commiting changes ...")
+ self.tgt_connection.commit()
+
+ finally:
+ cur.close()
+
+
# -------------------------------------------------------------------------
def _close_all(self):