Set Up the Sample Application
Learn how to set up a sample application and get a real feel for Ecto.
How is Ecto organized?
Under the hood, Ecto is actually two separate packages; ecto
and ecto_sql
. The ecto
package contains some of the core data manipulation features that are useful even if we’re not using a relational database. These include the Repo
, Query
, Schema
, and Changeset
modules, among others.
The ecto_sql
package, on the other hand, contains modules specifically needed to communicate with relational databases. These include the various database-specific adapters, migrations, and so forth.
Ecto with relational database
The ecto_sql
package includes ecto
as a dependency. If we’re using Ecto to work with a relational database, we need to include ecto_sql
in our dependencies to get ecto
in the process. Suppose we’re not working with a relational database and want to take advantage of some of the data manipulation features that Ecto offers, such as validations, though. In that case, we can include ecto
rather than ecto_sql
to make our dependency tree a little lighter.
Get hands-on with 1400+ tech skills courses.