更新时间:2023-02-02 21:53:44
我不知道要用于复制的纯Python 的程度,但是您可以仅委派整个管道对外壳进行操作.
I don't know the degree of pure Python you want to use for the copy, but you can just delegate the entire pipe operation to the shell.
subprocess.Popen('mysqldump -h localhost -P 3306 -u -root mydb | mysql -h localhost -P 3306 -u root mydb2', shell=True)
这应该与在shell上运行时的工作方式相同.
This should work the same way it works when you run it on the shell.