小编And*_*ray的帖子

如何在Elixir回购中添加来自STDIN的COPY

我正在尝试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)

elixir ecto

3
推荐指数
1
解决办法
477
查看次数

标签 统计

ecto ×1

elixir ×1