我正在尝试Elixir Ecto,现在我需要在代码中实现COPY FROM STDIN。我在github上的postgrex.ex中找到了示例:
Postgrex.transaction(pid, fn(conn) ->
query = Postgrex.prepare!(conn, "", "COPY posts FROM STDIN",[copy_data:true])
stream = Postgrex.stream(conn, query, [])
Enum.into(File.stream!("posts"), stream)
end)
Run Code Online (Sandbox Code Playgroud)
我如何才能将其转换为我的需求。我必须通过什么pid?
Repo.transaction fn ->
query = "some query"
Ecto.Adapters.SQL.query!(Repo, query, [])
#copy from stdin, how??
end
Run Code Online (Sandbox Code Playgroud)