How to change connection params at run time

Hi everyone, I looked at the documentation and it seems like the only way to change the connection is to have them defined in the configuration. But in my case, the database credentials will be stored in my database and it’s defined by the user. The database I should connect to depends on the request. So, I need to pull the database credentials from the database and dynamically change the connection. Can someone, advise me an appropriate approach? I’m considering requiring knex directly.