Not exactly as you want, but Template::Toolkit allows you to make SQL query directly from your template.
In reply to Re: Template engine question by zwon in thread Template engine question by stan_b