I am very new to the world of Elixir and Phoenix Framework. I am trying to follow TheFireHoseProject tutorial, but have problems querying raw SQL with Ecto. The manual says this should work:
defmodule Queries do def random do query = Ecto.Adapters.Postgres.query( Repo, "SELECT id, saying, author from quotes ORDER BY RANDOM() LIMIT 1", []) %Postgrex.Result{rows: [row]} = query {id, saying, author} = row %Splurty.Quote{id: id, saying: saying, author: author} end end
I get a runtime error that Ecto.Adapters.Postgres.query does not exist (function undefined).
I tried searching the Ecto documentation and found that there might be a run_query function, but it also does not work.
I think I am using Ecto 1.1.4 and I have not found any good (modern) samples of how I can query the source SQL with Ecto.
Link to the firehose project: http://phoenix.thefirehoseproject.com/
elixir phoenix-framework
Antti simonen
source share