Can ecto repos be started dynamically?

As per @josevalim’s suggestion.


So I wanted to be able to dynamically open databases, for example, on first insert or read, and then close them after either some period of inactivity or manually without affecting other databases. For that I needed a repo per such a database. I’ve documented my first attempt above.

Since then I’ve moved on to working with esqlite directly.

what you are doing right now, the pros and cons

I suppose this is about my current approach (esqlite).

Pros: all the logic about opening / migrating / interacting / and then closing the databses is clear.

Cons: I have to write SQL manually.


As for why I’m doing it, I’m deploying to a variable environment where machines come and go so I needed a databases system that would “travel” together with the app, so I picked sqlite thus making the elixir app into a databases. But in order to avoid write conflicts, each resource gets it’s own database.

In the end I want to achieve something not quite unlike http://actordb.com but without raft or any other form of coordination.

1 Like