"Northwind Elixir Traders" updated: importing data from a dynamic Ecto repo

“Northwind Elixir Traders” updated: importing data from a dynamic Ecto repo

20 May, 2024 2 min read
software, programming, Elixir, learning, Ecto, databases, book

This update to the “Northwind Elixir Traders” book took longer than usual. Life got in the way, and then I also got stuck with attempting to implement a clever-and-complicated solution to one of the things in this chapter using Enum.reduce_while/3 (after learning some cool things while working on IdenticonSvg , I unsuccessfully tried to construct a dependency tree between tables).

Still, this update is a medium-large one. 37 new pages have been added, and they cover using a dynamic Ecto repository to temporarily connect to a different SQLite database, inserting data in bulk, and various bits and pieces of Elixir that aren’t directly related to Ecto, but useful when writing Elixir applications and avoiding the hard-coding of data within them, regardless, such as the :application, Application and Module modules, the Kernel.apply/3 function, and the use of the __MODULE__ attribute.

Here’s the ToC excerpt for this new chapter:

Chapter on importing data from a dynamic Ecto repository

With half of the tables having been modeled to a satisfactory degree over the past 9 chapters, the content of this chapter finally allows us to gradually import data from the original Northwind Traders database to tables as we gradually model them. With some laziness-driven automation through the DataImporter module, this will make such tasks in the next chapters fly by.

In the next chapters we can proceed with modeling the rest of the tables rapidly. My interim goal is to have all of the original dataset imported, and thus be able to execute queries both complex and simple. After the “basic” task of having the entire database implemented using Ecto, the goal is to branch out and explore the fringes a bit; consider improvements to the database to take it further, using embedded schemas and Enums, and other nooks and crannies of Ecto.

I’ve marked the completion degree as 28% but it’s closer to 75% realistically. Then again… famous last words. Pretty sure that the head shall meet the desk percussively and repeatedly many times over the next weeks.