Ecto: Data Mapping and Language Integrated Query for Elixir
A toolkit for data mapping and language integrated query.
At a glance
- What is it?
- Ecto is a toolkit for data mapping and language integrated query in Elixir, commonly paired with adapters such as Ecto.Adapters.Postgres. It is a library, not a full ORM, and its schemas, changesets and queries are separate pieces you compose yourself.
- Who is it for?
- Ecto fits Elixir teams that want explicit schemas, composable queries and a changeset layer they control, and it is a poor fit for anyone expecting an ActiveRecord-style object graph with lazy loading and automatic persistence.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly Elixir, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- elixir-ecto/ecto6,503 ★ · +4
| Repository | 2026-09-23 | 2026-11-15 |
|---|---|---|
| elixir-ecto/ecto | 6.5k | 6.5k |
4 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What Ecto Solves, and Who It Is Written For
Ecto is a toolkit for data mapping and language integrated query for Elixir. That phrasing in the README matters, because it separates two jobs that many persistence libraries merge: turning external data into Elixir structs, and expressing queries in Elixir syntax that an adapter translates for a data store. The README states that Ecto is commonly used to interact with databases such as PostgreSQL and MySQL via Ecto.Adapters.SQL, and that it is also commonly used to map data from any source into Elixir structs, whether those structs are backed by a database or not. The second half is the part people miss. You can define a schema for a CSV import, an HTTP payload or a message queue record and still get the field declarations, with no database anywhere in the picture.
The audience is Elixir developers who want query composition as ordinary functions. In a codebase where filters arrive from user input, that composability is the whole point. If you are coming from a framework where queries are strings assembled at runtime, the difference in how you structure that code is substantial.
Ecto is not a standalone product. The README points to the getting started guide and the online documentation at hexdocs.pm/ecto as the real sources, and it lists two books: Programming Ecto by Darin Wilson and Eric Meadows-Jönsson, and the free The Little Ecto Cookbook from Dashbit. The repository itself carries guides/, lib/, test/, integration_test/ and an examples/ directory containing examples/friends/, so the reading path is documentation first, source second. Nothing in the README promises an ORM, and the toolkit framing should be taken literally.
Schemas, Changesets and the Adapter Boundary
A schema is a module that declares fields and their types. The README's Sample.Weather defines schema "weather" with field :city (which the comment says defaults to type :string), field :temp_lo, :integer, field :temp_hi, :integer, and field :prcp, :float, default: 0.0. The default: option is applied in Elixir, not by the database, so a struct built without :prcp gets 0.0 before anything is sent anywhere. That distinction between struct-level defaults and column-level defaults is a recurring source of confusion and the README does not spell it out.
The repository definition is the second piece. Sample.Repo uses Ecto.Repo with otp_app: :my_app and adapter: Ecto.Adapters.Postgres. That module becomes the entry point for Repo.all and friends, and the adapter is what makes the same query syntax target a different engine. The README's adapter table lists PostgreSQL with Ecto.Adapters.Postgres, MySQL with Ecto.Adapters.MyXQL, MSSQL with Ecto.Adapters.Tds, SQLite3 with Ecto.Adapters.SQLite3, ClickHouse with Ecto.Adapters.ClickHouse, and ETS through Etso. Only the first three run through ecto_sql; SQLite3, ClickHouse and ETS pull in separate packages, which means their feature coverage is decided outside this repository.
Changesets are the third piece and the README does not demonstrate them at all; for those you have to go to the guides or hexdocs.pm/ecto.
Installing Ecto and Running a First Query
Ecto is published on Hex, and the README gives the dependency line directly. Add it to the deps list in mix.exs:
def deps do
[
{:ecto, "~> 3.10"}
]
endThat alone gives you schemas and queries but no database connection. For a real database you add the adapter pair instead. The README's PostgreSQL example uses ecto_sql and postgrex:
defp deps do
[
{:ecto_sql, "~> 3.0"},
{:postgrex, ">= 0.0.0"}
]
endRun mix deps.get in your shell to fetch the dependencies, as the README instructs. Then configure the repository in config/config.exs. The README's example uses a database named ecto_simple, username postgres, password postgres, hostname localhost and port "5432":
config :my_app, ecto_repos: [Sample.Repo]
config :my_app, Sample.Repo,
database: "ecto_simple",
username: "postgres",
password: "postgres",
hostname: "localhost",
port: "5432"Finally define the repository module and point it at the adapter. For PostgreSQL the README shows:
defmodule MyApp.Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Ecto.Adapters.Postgres,
...If your host resolves to an IPv6 address, the README says to add socket_options: [:inet6] to the configuration block, and it shows that option alongside hostname. The README does not document how to create the database, run migrations, or roll back a failed migration; those steps live in the getting started guide rather than here.
Where Ecto Stops Being the Right Tool
Ecto is a toolkit, and the README's own wording sets the boundary. There is no lazy loading, no identity map and no automatic persistence of a modified struct. A struct you change in memory stays changed in memory until you pass it through a repository call, and the README does not describe any mechanism that would do otherwise. Teams used to an object graph where touching an association triggers a query will find that Ecto simply does not work that way, and the adjustment is architectural rather than cosmetic.
The adapter table is a second boundary. MSSQL runs through Ecto.Adapters.Tds, which the README links to a third-party repository, and SQLite3, ClickHouse and ETS likewise depend on packages outside this project. If your database is not in that table, Ecto is not the tool for you unless you write an adapter. Even inside the table, the adapter decides what SQL features are available, so query behaviour can differ between PostgreSQL and MySQL in ways this repository does not govern.
Version support is the third constraint and it is unusually strict. The README's supported versions table lists v3.12 for bug fixes, v3.11, v3.10, v3.9 and v3.8 for security patches only, and v3.7 and earlier as unsupported. The README states that with version 3.0 the Ecto API has become stable and that the main focus is on bug fixes and incremental changes. That is a deliberate trade: you get a stable surface, and you should not expect new capability to arrive quickly. The most recent release listed for this repository is v3.4.5 from 2020-07-28, while the last push to the default branch was on 2026-11-01, so the repository is active in a maintenance and incremental-change sense rather than a feature-release sense.
Ecto Against a Conventional ORM
The clearest comparison is with a conventional ORM in the ActiveRecord tradition, where a model class owns both the schema and the persistence methods, and associations load on demand. Ecto splits those responsibilities. The schema module declares fields. The repository module owns the connection and the adapter. Queries are values you build with functions from Ecto.Query. Changesets, which the README does not cover, sit between external input and the struct. The practical difference is that nothing happens implicitly: a query is not executed until you hand it to Repo.all or an equivalent, and a struct is not written until you ask.
That split has a cost. There is more code to write for a simple create-and-read path, and a newcomer has to learn several modules before anything runs. The benefit appears when queries need to be assembled from optional filters, or when the same schema has to serve both a database table and an external payload. The README's statement that Ecto maps data from any source into Elixir structs, database-backed or not, is the design claim behind that benefit.
Within the Elixir ecosystem the closest thing to a like-for-like alternative is going straight to a driver such as postgrex and writing SQL. That removes the schema and query layers and gives you full control over the statement text. It also removes composition: chaining a where clause onto an existing query becomes string manipulation. Ecto sits above the driver rather than replacing it, and the README's PostgreSQL dependency list includes postgrex alongside ecto_sql, which reflects that arrangement.
Maintenance Cost and the Apache-2.0 Licence
The repository is not archived, and the last push to the default branch was on 2026-11-01. The supported versions table is the clearest statement of maintenance policy: v3.12 receives bug fixes, v3.11 down to v3.8 receive security patches only, and v3.7 and earlier are unsupported. The README adds that since version 3.0 the API has become stable and the focus is bug fixes and incremental changes. For an adopter, the upgrade cost is therefore mostly the cost of moving between minor branches on a stable API, plus whatever your adapter package requires. The README does not publish a deprecation timeline or an end-of-life date for any branch.
Ecto is licensed under Apache-2.0. The README carries the standard Apache License, Version 2.0 text and the copyright lines: Copyright (c) 2013 Plataformatec and Copyright (c) 2020 Dashbit. Apache-2.0 is a permissive licence that includes an explicit patent grant, and it requires that you retain the licence and notice files when redistributing. That is a description of the licence text, not legal advice; if your organisation has specific obligations around attribution or modification notices, have counsel read the LICENSE.md in the repository rather than relying on a summary.
One branding constraint sits alongside the licence. The README states that "Ecto" and the Ecto logo are Copyright (c) 2020 Dashbit, and that the logo was designed by Dane Wesolko. The licence covers the code; it does not grant you the name or the mark. If you fork and redistribute under your own brand, that distinction is worth checking before you ship.
Editorial conclusion
Ecto fits Elixir teams that want explicit schemas, composable queries and a changeset layer they control, and it is a poor fit for anyone expecting an ActiveRecord-style object graph with lazy loading and automatic persistence. Before adopting it, confirm which adapter and ecto_sql version your database needs, check the supported versions table for the branch you are on, and read the getting started guide at hexdocs.pm/ecto because the README alone does not cover migrations or rollback behaviour.
Frequently asked questions
What is Ecto in Elixir?
Ecto is a toolkit for data mapping and language integrated query for Elixir. The README says it is commonly used with databases such as PostgreSQL and MySQL through adapters, and also to map data from any source into Elixir structs, whether or not a database backs them.
How do I install Ecto for PostgreSQL?
Add ecto_sql and postgrex to the deps list in mix.exs, run mix deps.get, then set adapter: Ecto.Adapters.Postgres in your repository module and add the connection settings under config/config.exs. The README's PostgreSQL example uses a database named ecto_simple on port "5432".
Which databases does Ecto support?
The README's table lists PostgreSQL with Ecto.Adapters.Postgres, MySQL with Ecto.Adapters.MyXQL, MSSQL with Ecto.Adapters.Tds, SQLite3 with Ecto.Adapters.SQLite3, ClickHouse with Ecto.Adapters.ClickHouse, and ETS through Etso. Only the first three run through ecto_sql; the others come from separate packages.
Is Ecto an ORM?
The README describes Ecto as a toolkit for data mapping and language integrated query rather than an ORM. Schemas declare fields, repository modules own the connection and adapter, and queries are values you build and then pass to a repository function such as Repo.all.
Which Ecto versions are still supported?
The README's supported versions table lists v3.12 for bug fixes, v3.11 down to v3.8 for security patches only, and v3.7 and earlier as unsupported. It also states that since version 3.0 the API has become stable and the focus is on bug fixes and incremental changes.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/elixir-ecto-ecto)Star history chart for your README
[](https://hysenlabs.com/projects/elixir-ecto-ecto)Was this useful?