Mysqlimport from pipe

ⅰ亾dé卋堺 提交于 2019-12-12 13:27:44

问题


I'm trying to figure out how to pipe output into mysqlimport without any luck. I have a huge file (~250 GB) that I want to pipe to mysqlimport after processing it. I don't want to create an intermediate file/table. I'm imagining something like this:

cat genome.mpileup | nawk 'sub("^...","")' | mysqlimport -uuser -ppassword Database

But obviously this isn't working. Any suggestions on how to accomplish this?


回答1:


It doesn't look like mysqlimport can read from STDIN but you can perhaps experiment with a named pipe. Something like this (untested)

mkfifo bigfile
mysqlimport -uuser -ppassword Database bigfile &
cat genome | nawk > bigfile

Or you can use an extension to bash to run commands instead of files

mysqlimport -uuser -ppassword Database <(cat genome | nawk)


来源:https://stackoverflow.com/questions/15841956/mysqlimport-from-pipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!