For related scenarios, see: Reading data from different MySQL databases using dynamically loaded connection parameters. Writing dynamic columns from a source file to a database.