server/sqlutils.py
branchstable
changeset 4854 b06d2a3b27d9
parent 4719 aaed3f813ef8
child 4893 15ae9a33a7f2
equal deleted inserted replaced
4846:a2fb82770fa6 4854:b06d2a3b27d9
   171         init_cnx(self.dbdriver, cnx)
   171         init_cnx(self.dbdriver, cnx)
   172         #self.dbapi_module.type_code_test(cnx.cursor())
   172         #self.dbapi_module.type_code_test(cnx.cursor())
   173         return cnx
   173         return cnx
   174 
   174 
   175     def backup_to_file(self, backupfile):
   175     def backup_to_file(self, backupfile):
   176         for cmd in self.dbhelper.backup_commands(self.dbname, self.dbhost,
   176         for cmd in self.dbhelper.backup_commands(backupfile=backupfile,
   177                                                  self.dbuser, backupfile,
   177                                                  keepownership=False,
   178                                                  dbport=self.dbport,
   178                                                  dbname=self.dbname,
   179                                                  keepownership=False):
   179                                                  dbhost=self.dbhost,
       
   180                                                  dbuser=self.dbuser,
       
   181                                                  dbport=self.dbport):
   180             if _run_command(cmd):
   182             if _run_command(cmd):
   181                 if not confirm('   [Failed] Continue anyway?', default='n'):
   183                 if not confirm('   [Failed] Continue anyway?', default='n'):
   182                     raise Exception('Failed command: %s' % cmd)
   184                     raise Exception('Failed command: %s' % cmd)
   183 
   185 
   184     def restore_from_file(self, backupfile, confirm, drop=True):
   186     def restore_from_file(self, backupfile, confirm, drop=True):
   185         for cmd in self.dbhelper.restore_commands(self.dbname, self.dbhost,
   187         if 'dbencoding' in self.dbhelper.restore_commands.im_func.func_code.co_varnames:
   186                                                   self.dbuser, backupfile,
   188             kwargs = {'dbencoding': self.encoding}
   187                                                   self.encoding,
   189         else:
       
   190             kwargs = {'encoding': self.encoding}
       
   191         for cmd in self.dbhelper.restore_commands(backupfile=backupfile,
       
   192                                                   keepownership=False,
       
   193                                                   drop=drop,
       
   194                                                   dbname=self.dbname,
       
   195                                                   dbhost=self.dbhost,
       
   196                                                   dbuser=self.dbuser,
   188                                                   dbport=self.dbport,
   197                                                   dbport=self.dbport,
   189                                                   keepownership=False,
   198                                                   **kwargs):
   190                                                   drop=drop):
       
   191             if _run_command(cmd):
   199             if _run_command(cmd):
   192                 if not confirm('   [Failed] Continue anyway?', default='n'):
   200                 if not confirm('   [Failed] Continue anyway?', default='n'):
   193                     raise Exception('Failed command: %s' % cmd)
   201                     raise Exception('Failed command: %s' % cmd)
   194 
   202 
   195     def merge_args(self, args, query_args):
   203     def merge_args(self, args, query_args):