Untitled notebook
Mix.install([
{:meadow_kino, path: "/home/ec2-user/environment/meadow_kino"},
{:kino_db, "~> 0.2.3"}
])
Section
require Kino.RPC
node = String.to_atom(System.fetch_env!("LB_MEADOW_NODE"))
Node.set_cookie(node, String.to_atom(System.fetch_env!("LB_MEADOW_COOKIE")))
Kino.RPC.eval_string(node, ~S"Meadow.Data.Schemas.Work |> Meadow.Repo.aggregate(:count)",
file: __ENV__.file
)
require Kino.RPC
node = String.to_atom(System.fetch_env!("LB_MEADOW_NODE"))
Node.set_cookie(node, String.to_atom(System.fetch_env!("LB_MEADOW_COOKIE")))
db_opts =
Kino.RPC.eval_string(
node,
~S"""
Application.get_env(:meadow, Meadow.Repo)
|> Keyword.take([:hostname, :port, :username, :password, :database])
""",
file: __ENV__.file
)
{:ok, conn} = Kino.start_child({Postgrex, db_opts})
result =
Postgrex.query!(
conn,
"select id::text, descriptive_metadata->>'title' from works limit 100",
[]
)