我需要读取原始的Postgres输出并迭代行值。
ww = %Postgrex.Result{columns: ["id", "tracking_link"], command: :select,
connection_id: 22311, num_rows: 14,
rows: [[2, "http://StarChef.com?id=1"],
[3, "http://CaptainAmerica:TWSLiveWP.com?id=2"]]}
ww [:rows] - 不提供输出
答案 0 :(得分:0)
您需要使用.
来访问结构的字段。括号语法仅适用于不是实现Access
行为的结构或结构的映射。
iex(1)> ww = %Postgrex.Result{columns: ["id", "tracking_link"], command: :select,
...(1)> connection_id: 22311, num_rows: 14,
...(1)> rows: [[2, "http://StarChef.com?id=1"],
...(1)> [3, "http://CaptainAmerica:TWSLiveWP.com?id=2"]]}
%Postgrex.Result{columns: ["id", "tracking_link"], command: :select,
connection_id: 22311, num_rows: 14,
rows: [[2, "http://StarChef.com?id=1"],
[3, "http://CaptainAmerica:TWSLiveWP.com?id=2"]]}
iex(2)> ww.rows
[[2, "http://StarChef.com?id=1"],
[3, "http://CaptainAmerica:TWSLiveWP.com?id=2"]]