Interface external database

My app should be able to connect to an external database and only read from it.

Is it possible to make a connection in a way which doesn’t require me to duplicate the complete scheme of the tables I will query?

Currently I have to implement a get function which will say something like

from(entry in MyApp.ExternDatabase.SomeSchema,
    order_by: [desc: entry.inserted_at],
    select: entry)
    |> Repo.all()

But for that, I would have to implement the MyApp.ExternDatabase.SomeSchema, is that correct?

What am I missing?

You can query tables without a schema. You need to define the select part of the query then though.

from x in "table_name", select: %{…}
3 Likes