| 
  | backupDatabase(user,
        password,
        backupFile,
        database=None)
   | source code |  Backs up an individual MySQL database, or all databases. This function backs up either a named local MySQL database or all 
  local MySQL databases, using the passed-in user and password (if 
  provided) for connectivity.  This function call always results a 
  full backup.  There is no facility for incremental backups. The backup data will be written into the passed-in backup file.  
  Normally, this would be an object as returned from open(), 
  but it is possible to use something like aGzipFileto write
  compressed output.  The caller is responsible for closing the passed-in 
  backup file. Often, the "root" database user will be used when backing up
  all databases. An alternative is to create a separate MySQL 
  "backup" user and grant that user rights to read (but not 
  write) all of the databases that will be backed up. This function accepts a username and password.  However, you probably 
  do not want to pass those values in.  This is because they will be 
  provided to mysqldumpvia the command-line--userand--passwordswitches, which will be 
  visible to other users in the process listing. Instead, you should configure the username and password in one of 
  MySQL's configuration files.  Typically, this would be done by putting a 
  stanza like this in /root/.my.cnf, to providemysqldumpwith the root database username and its 
  password: 
  [mysqldump]
  user     = root
  password = <secret>
 If you are executing this function as some system user other than 
  root, then the .my.cnffile would be placed in the home 
  directory of that user.  In either case, make sure to set restrictive 
  permissions (typically, mode0600) on.my.cnfto make sure that other users cannot read the file. 
    Parameters:
        user(String representing MySQL username, orNone) - User to use for connecting to the database (if any)password(String representing MySQL password, orNone) - Password associated with user (if any)backupFile(Python file object as fromopen()orfile().) - File use for writing backup.database(String representing database name, orNonefor all 
          databases.) - Name of the database to be backed up.Raises:
        ValueError- If some value is missing or invalid.IOError- If there is a problem executing the MySQL dump. |