On 26/09/12 01:17:24, bruceg113...@gmail.com wrote: > 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?
* If there are shell meta characters in the password, you'd have need to use single quotes, as in -p'%s'. Actually, that's true for any of the parameters, but the password is one most likely to contain punctuation characters. * You could try print("mysqldump -u %s -p%s -h %s -e --opt -c %s | gzip -c > %s.gz" % (user,password,host,database,database+"_"+filestamp)) and if the result looks okay, copy and paste it to the command line (do not retype; use copy and paste) and see if it works. * In your script, add a line os.popen("monty_python") This should produce an error message. If it doesn't, find out why. * Check the timestamp of your empty output file. If it was created yesterday, then maybe your script is now writing its file in another directory and you're looking at the output of yesterday's test. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list