I have a script that connects to multiple databases (Oracle, MySQL and MSSQL), each database connection might not be used each time the script runs but all could be used in
The best performance/practice rule is simple: do connect to one database only.
As for the connects - try to implement some database access class. Which can connect automatically on demand.