mbklein

mbklein

Using Ecto.Query in a RemoteExecutionCell

I’ve got Livebook (using the livebook:edge Docker container) set up and properly executing code on a remote node (though I have some configuration questions that I’ll address in a different topic). The only major problem I’m having comes when I try to use Ecto.Query.

If I try to import Ecto.Query, I get an error that says error: module Ecto.Query is not loaded and could not be found.

If I try to use Ecto.Query.from(...) directly without importing it, I get

** (ErlangError) Erlang error: {:exception, :undef, [{Ecto.Query, :from, [Meadow.Data.Schemas.Work, [limit: 1]], []}, {:elixir_eval, :__FILE__, 1, [file: ~c"#cell:gsynocyaqcunidcyirskfy2tyhh2wirn", line: 5]}, {:elixir, :"-eval_external_handler/1-fun-2-", 4, [file: ~c"src/elixir.erl", line: 376]}, {:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 750]}, {:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1026]}, {:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 456]}]}
    (kernel 9.0.2) erpc.erl:702: :erpc.call/5
    #cell:gsynocyaqcunidcyirskfy2tyhh2wirn:4: (file)

If I try to require it before using it that way, I get the ...is not loaded and could not be found error again.

Oddly, remote autocomplete finds it just fine:

Other macros (like Logger.warning/2) seem to work just fine, so it doesn’t seem to be a macro issue.

Can anyone provide any guidance or answers on this?

Marked As Solved

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @mbklein as a basic question, did you Mix.install ecto as a dependency? Can you show the failing livebook?

Also Liked

mbklein

mbklein

Yup, adding ecto as a dependency of the local notebook got it working.

It’s so easy to lose track of what’s building which AST and passing it off to where in an RPC situation, but it makes sense that macros need to be evaluated before the remote call is made.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement