tablecopy.py
changeset 96 acf63df539b7
parent 93 b72591087495
child 104 d8ff52a0390f
equal deleted inserted replaced
95:6adcb7ee4517 96:acf63df539b7
    21 
    21 
    22         self.parser.add_argument('-n', '--no-action', dest='noaction', action='store_true',
    22         self.parser.add_argument('-n', '--no-action', dest='noaction', action='store_true',
    23             help="Do nothing, just print tables to be copied. Useful in combination with --regex.")
    23             help="Do nothing, just print tables to be copied. Useful in combination with --regex.")
    24         self.parser.add_argument('--no-sort', dest='nosort', action='store_true',
    24         self.parser.add_argument('--no-sort', dest='nosort', action='store_true',
    25             help="Do not sort. By default, tables are sorted by foreign key references.")
    25             help="Do not sort. By default, tables are sorted by foreign key references.")
       
    26         self.parser.add_argument('--disable-triggers', dest='notriggers', action='store_true',
       
    27             help="Disable all triggers for the session.")
    26 
    28 
    27         self.init()
    29         self.init()
    28 
    30 
    29     def main(self):
    31     def main(self):
    30         self.srcconn = self.pgm.get_conn('src')
    32         self.srcconn = self.pgm.get_conn('src')
    31         self.dstconn = self.pgm.get_conn('dst')
    33         self.dstconn = self.pgm.get_conn('dst')
       
    34 
       
    35         if self.args.notriggers:
       
    36             curs = self.dstconn.cursor()
       
    37             curs.execute('SET session_replication_role = replica;')
       
    38             curs.close()
       
    39             self.dstconn.commit()
    32 
    40 
    33         dc = pgdatacopy.PgDataCopy(self.srcconn, self.dstconn)
    41         dc = pgdatacopy.PgDataCopy(self.srcconn, self.dstconn)
    34 
    42 
    35         if self.args.nosort:
    43         if self.args.nosort:
    36             for table in self.tables():
    44             for table in self.tables():