In <[EMAIL PROTECTED]>, John Pye wrote:

> I am trying to set up a python script to manage backups of a mysql
> database the 'right way' using pipes. I want to send the output of the
> 'mysqldump' command to a file. Using a normal shell script this would
> be easy using a ">" operator. What is the efficient and best way to do
> this using pure python, bearing in mind that it will be too much data
> to keep in memory? I presume using the subprocess module, but how to
> get the output to a file? It's not really documented, AFAICS.

I think it is documented, that's what the `stderr` and `stdout` arguments
are used for.  Untested:

    f = open('dump.txt', 'wb')
    p = Popen(('mysqldump', '--option', '--another-option'), stdout=f)
    r = p.wait()

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to