How can in compress the mysqldump with Python Popen

I am using command to dump the database

pipe = subprocess.Popen("mysqldump -e --opt --skip-lock-tables  --skip-extended-insert -c %s > %s" % (database, filename), shell=True)

But it produces sql file

is there any to compress to make tar.gz from the same command

Answers


You can use gzip for compression. Then the command for Popen() looks like:

"mysqldump -e --opt --skip-lock-tables  --skip-extended-insert -c %s | gzip > %s.gz"

It produces a .gz file with the same compression rate as .tar.gz. You don't need to build a .tar archive as you have just a single file.


Need Your Help

Show a form's response in browser instead of Lotus Notes Tab

forms lotus-notes html-email

this is the first time I work with email forms for Lotus Notes - should the answer be too simple, please forgive me.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.