I see no reason given the code provided, that this has to be done via eval. Do a $dbh->do($generated_table_data). I would recommend using the quoting or placeholder functions, if at all possible, of the dbi to avoid Bobby Tables issues.
You are stringifying the reference for the $dbh, which is where the DBI::db=HASH... stuff is coming from. Don't do that. As I said in the last point, eval is not necessary here.