作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的脚本中有一个命令是这样的
MESSAGE=`grep -Po 'MSG.\K[\w\s,.'\'',.:]*' < $FILENAME`
现在当这个命令运行时,我有一个看起来像这样的输出
Kohl's EDI will be down for scheduled maintenance starting at 12:30 am until
approximately 4:00 am central time on Wednesday June 22nd. Kohl's will not be
able to send or receive EDI or AS2 transmissions during this time. If your
company's AS2 software has an automated process to resend a file after a
failure, Kohl's encourages your company to enable the resend process. This is
also a reminder for AS2 trading partners that Kohl's AS2 certificate will be
changing at 11:00 am central time on Tuesday June 21st.
现在,在 grep 全部内容后,我会将命令的结果传递给一个将要使用的变量,以便我可以将结果存储到 mysql 数据库中
问题是我将如何做?
最佳答案
确保您已从服务器连接到 mysql,然后您可以在插入语句中传递 MEASSGE 变量作为 \"$MESSAGE\"
- \
是因为包装有效插入语句的双引号消息。
测试:我没有足够大的列来存储您的整个消息,因此我将其略微修剪以适合该列:
> MESSAGE="Kohl's EDI will be down for scheduled maintenance starting at 12:30 am until
approximately 4:00 am central time on Wednesday June 22nd. Kohl's will not be
able to send or receive EDI or AS2 transmissions during this time. If your
company's AS2 software has an automated process to resend a file after a
"
> sql "insert into at_test_run (run_id,run_error) values ('10000111',\"$MESSAGE\");"
> sql "select run_id,run_error from at_test_run where run_id='10000111'"
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| run_id | run_error |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 10000111 | Kohl's EDI will be down for scheduled maintenance starting at 12:30 am until
approximately 4:00 am central time on Wednesday June 22nd. Kohl's will not be
able to send or receive EDI or AS2 transmissions during this time. If your
company's AS2 software has an automated process to resend a file after a
|
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
关于mysql - 如何在mysql数据库中插入多行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37982128/
我是一名优秀的程序员,十分优秀!