@cost_time
def dbdump_all():
"导出数据库所有数据至当前目录下以年月日命名的sql文件"
filename=datetime.datetime.now().strftime("%Y-%m-%d")
cmd="""mysqldump -u root -pzhoubt --opt --quick --database search > ./%s.sql"""%filename
args=shlex.split(cmd)
p=subprocess.Popen(args)
#stdout, stderr = p.communicate()
#print stdout,stderr
print "已将数据库表结构和数据导出到%s"%filename
I use the mysqldump
command in a subprocess, and it outputs a lot of information about the exported data, even if I comment out the stdout, stderr = p.communicate()
line. It's also very slow, even though I've tried the same command in a shell and it's very quick and succinct. How can I avoid all the verbosity when using subprocess
, and speed up the time it takes to be more like running it directly from a shell?