Need to archive a MySQL database using a python script

bruceg113355 at gmail.com bruceg113355 at gmail.com
Tue Sep 25 19:17:24 EDT 2012


Python Users Group,

I need to archive a MySQL database using a python script.
I found a good example at: https://gist.github.com/3175221

The following line executes however, the archive file is empty.

os.popen("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" %
               (user,password,host,database,database+"_"+filestamp))
Where:
  User     = “someUser”
  password = “somePassword”
  host     = “someRemote.database.server”
  database = “someDatabase”

If I execute mysqldump from the command line, an archive is created.

Using Python 2.6 and MySQL-python-1.2.2.win32-py2.6 (MySQLdb)
Mysql-5.5.27 from the command line.

Any ideas?

Thanks,
Bruce



More information about the Python-list mailing list