How to set the database path to load for use with Ecto, Sqlite3 after the program has started?

On the website (GitHub - elixir-sqlite/ecto_sqlite3: An Ecto SQLite3 adapter.), it states that I have to set the database path in the config file:

config :my_app,
  ecto_repos: [MyApp.Repo]

config :my_app, MyApp.Repo,
  database: "path/to/my/database.db"

The problem with this is it limits how many databases I can query from.

I need some way to set the database path so that it loads the file based on the year I specify somewhere in my program. I’m hoping to be able to do something like this to the path “databases/#{User.db.year}/database.db” after the program has loaded.

How do I achieve this?

Thanks.

2 Likes

Ecto.Repo — Ecto v3.12.5 can be used for that.

2 Likes

Simple. Perfect. Problem solved! Thank you.