View Source README

Easily debug and pretty print your Ecto SQL queries
Contents
installation
Installation
Available in Hex, the package can be installed by adding ecto_dbg to your list of
dependencies in mix.exs:
def deps do
[
{:ecto_dbg, "~> 0.1.0", only: [:dev, :test]}
]
endDocumentation can be found at https://hexdocs.pm/ecto_dbg.
supporting-ectodbg
Supporting EctoDbg
If you rely on this library help you debug your Ecto queries, it would much appreciated if you can give back to the project in order to help ensure its continued development.
Checkout my GitHub Sponsorship page if you want to help out!
gold-sponsors
Gold Sponsors

silver-sponsors
Silver Sponsors

bronze-sponsors
Bronze Sponsors

setting-up-ectodbg
Setting Up EctoDbg
After adding {:ecto_dbg, "~> 0.1.0", only: [:test, :dev]} in your mix.exs file and running
mix deps.get, open your repo.ex file and add the following contents:
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
unless Mix.env() == :prod do
use EctoDbg
end
endYou can also pass configuration options to EctoDbg if you so chose like so (see the EctoDbg module docs
for more information):
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres
unless Mix.env() == :prod do
use EctoDbg, level: :info
end
endWith that in place, any time that you want to inspect a query that is executed by Ecto, all you need to do is the following
query = from user in User
Repo.all_and_log(query)
attribution
Attribution
- EctoDbg builds upon the EctoDevLogger package and has reused some of the code in that project to achieve a slightly different goal.
- The logo for the project is an edited version of an SVG image from the unDraw project.
- The EctoDbg library wraps pgFormatter in order to provide SQL formatting.