我得到了“IOError:[Errno 32] Broken pipe”,而在linux中编写文件。
我正在使用python来读取csv文件的每一行,然后写入数据库表。 我的代码是
f = open(path,'r') command = command to connect to database p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env) query = " COPY myTable( id, name, address) FROM STDIN WITH DELIMITER ';' CSV QUOTE '"'; " p.stdin.write(query.encode('ascii')) *-->(Here exactly I got the error, p.stdin.write(query.encode('ascii')) IOError: [Errno 32] Broken pipe )*
所以当我在linux中运行这个程序时,出现错误“IOError:[Errno 32] Broken pipe”。 但是,这个工作正常,当我在Windows7中运行。
我需要在Linux服务器上进行一些configuration吗?
任何build议将不胜感激。 谢谢。
您的pipe道已损坏 – 子stream程已经退出。 您用来连接数据库的命令已经完成。
这可能是与数据库通信的最糟糕的可能方式。 有问题的数据库types使用本机库。 我甚至不会试图列举所有这些不好的原因,只是改变它。 相信我。