hiera-mysql will do what you want. With Hiera-mysql, you would configure your MySQL database as a hiera backend, and access the data you want using
lookup() function calls.
Otherwise, it should be relatively trivial to write a custom function call that queries mysql and returns an array or hash.
I have enough programming skills in Ruby, in a BASH or Python. By this writing your own backend for Puppet - not solutions. I find it easier to write analogue Puppet Than backend.
To the best of my knowledge, no one has published a mysql lookup function for Puppet (nothing turned up on the forge, or on Google.)
A custom function is not a backend for Puppet; it's simply an interface that allows you to write Ruby code to handle tasks that aren't possible in the Puppet DSL. Anytime a lookup is performed in the DSL, a function is called. The requested syntax in your original post appears to be a function call as well.
Here's an example of the function call to query CSV files.
Your question is already answered here. I did not recommend generate specifically because you requested an array;
generate() would produce a string that you would need to split.
As an aside, not liking an answer doesn't make the answer wrong.