Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Connecting to the database

In the introduction, we hinted at how we'll use Ecto to store our application data in a PostgreSQL database. Ecto is able to connect to many databases, but for each database it needs the respective driver to establish the connection, support queries, and so on.

In our case we'll use the postgrex library, which provides the PostgreSQL Elixir driver. But don't think Ecto is tied to PostgreSQL in any way, because Ecto supports other databases like MySQL, DynamoDB, and SQLite, among others.

Let's start by adding the ecto and postgrex libraries to our elixir_drip umbrella app dependencies:

$ cat apps/elixir_drip/mix.exsdefmodule ElixirDrip.Mixfile do  use Mix.Project  defp deps do    [      {:postgrex, "~> 0.13"}, {:ecto, "~> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content