[英]How to capture output of PSQL command using PG gem?
I am trying to copy data into redshift from s3.我正在尝试将数据从 s3 复制到 redshift。 While running the following:在运行以下内容时:
1.9.2p320 :017 > res = psql_conn.exec("copy table_name from 's3_path' CREDENTIALS 'aws_access_key_id=xxxx;aws_secret_access_key=xxxx' delimiter '|' timeformat 'YYYY-MM-DD HH:MI:SS' REMOVEQUOTES NULL AS 'NULLL' MAXERROR AS 500 ACCEPTANYDATE TRUNCATECOLUMNS COMPUPDATE OFF;")
INFO: Load into table 'table_name' completed, 1 record(s) loaded successfully.
INFO: Load into table 'table_name' completed, 2 record(s) could not be loaded. Check 'stl_load_errors' system table for details.
=> #<PG::Result:0x007ff90b9c6240>
My question is how do I capture the INFO: rows into a variable or know if some stl_load_error occured?我的问题是如何将 INFO: rows 捕获到变量中或知道是否发生了某些 stl_load_error?
如果相应地配置,这些最终会在日志中......我很确定你不能使用变量捕获它们,除非暂时将( $stdout
或) $stderr
替换$stdout
你随后可以关闭和阅读的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.