There is now a generic way to do this:
https://community.dynatrace.com/t5/Dynatrace-tips/Custom-Database-Queries/td-p/185781