python popen and mysql import
Posted
by khelll
on Stack Overflow
See other posts from Stack Overflow
or by khelll
Published on 2010-05-02T10:45:41Z
Indexed on
2010/05/02
10:47 UTC
Read the original article
Hit count: 249
I'm doing the following:
from subprocess import PIPE
from subprocess import Popen
file = 'dump.sql.gz'
p1 = Popen(["gzip", "-cd" ,file], stdout=PIPE)
print "Importing temporary file %s" % file
p2 = Popen(["mysql","--default-character-set=utf8", "--user=root" , "--password=something", "--host=localhost", "--port=3306" , 'my_db'],stdin=p1.stdout, stdout=PIPE,stderr=PIPE)
err = p1.communicate()[1]
if err: print err
err = p2.communicate()[1]
if err: print err
But the db is not being populated. No errors are shown, also I have checked p1.stdout and it has the file contents. Any ideas?
© Stack Overflow or respective owner