How to change login, password, host of a Postgres database dynamically? Multiple databases

I have multipe Postgres repositories in my app. I use Ecto. All works. Now I want to be able to change their details, such as login, password, host, dynamically. That is, I’d change login/password/hostname of a database via an html page, restart the connection with a database and continue working with it.

How can I do that?

Yes, I’ve seen this topic How to connect to user-specified DB config using Ecto?
But I don’t want to use any third-party library

Or, can you recommend me an alternative to Ecto which will be a better fit for my task?

You can use postgrex directly, especially if you send raw SQL queries. If you want to use Ecto, then AFAIK there is no simple way to restart DB connection.

Ecto 3.1 added basic support for dynamic repos. This might be what you’re looking for.