For multiple databases, you have the database.php file where you can set as many databases as you need.
If you want to "switch" a database for a specific model on the fly, use the setDataSource() method.
For example, if you have two databases, you can define them in the database.php file as "default" and "sandbox", as an example.
Then, in your code:
The sandbox is the name of the configuration, and the actual name of the database is written only once in the database.php file.