SE-Radio Episode 349: Gary Rennie on Phoenix

Topics covered
Popular Clips
Episode Highlights
Ecto Basics
Ecto, a crucial component of Phoenix, serves as an abstraction layer for database interactions, allowing developers to define schemas and queries without writing raw SQL. explains that Ecto is not an ORM due to Elixir's lack of objects, but it provides a queryable struct to build transformations using its API 1. This struct is then executed against the database using the repository pattern, which supports multiple repositories for different data sources, including PostgreSQL, MySQL, and even MongoDB 2.
You define schemas for Ecto and you can define queries against those schemas.
---
Rennie highlights the flexibility of Ecto, noting its ability to use raw SQL fragments for unsupported functions and its dual query syntax inspired by C#'s LINQ 2.
Transaction Handling
Ecto's transaction handling capabilities are robust, offering explicit control over database operations through its multi feature. describes how Ecto allows for transactions that span multiple repositories and functions, ensuring that all operations succeed or fail together 3. This is particularly useful for complex operations, such as user registration processes that involve multiple steps like sending an SMS 3.
If the SMS fails, then we don't want the user to be inserted.
---
Additionally, Rennie explains that Ecto's transaction handling is explicit, requiring developers to specify which repository to use, thus avoiding any implicit database interactions 4.
Related Episodes


Episode 394: Chris McCord on Phoenix LiveView
Answers 383 questions

SE-Radio Episode 295: Michael Feathers on Legacy Code
Answers 383 questions
SE-Radio-Episode-249:-Vaughn-Vernon-on-Reactive-Programming-with-the-Actor-Model
Answers 383 questions

SE Radio 594: Sean Moriarity on Deep Learning with Elixir and Axon
Answers 383 questions

SE-Radio Episode 242: Dave Thomas on Innovating Legacy Systems
Answers 383 questions

SE-Radio Episode 279: Florian Gilcher on Rust
Answers 383 questions

SE-Radio Episode 276: Björn Rabenstein on Site Reliability Engineering
Answers 383 questions

SE-Radio-Episode-253-Fred-George-on-Developer-Anarchy
Answers 383 questions

SE-Radio Episode 247: Andrew Phillips on DevOps
Answers 383 questions

SE-Radio-Episode-267-Jürgen-Höller-on-Reactive-Spring-and-Spring-5.0
Answers 383 questions

SE-Radio Episode 313: Conor Delanbanque on Hiring and Retaining DevOps
Answers 383 questions

SE-Radio Episode 243: RethinkDB with Slava Akhmechet
Answers 383 questions

SE-Radio Episode 357: Adam Barr on Code Quality
Answers 383 questions

SE-Radio Episode 362: Simon Riggs on Advanced Features of PostgreSQL
Answers 383 questions














