Why not use Lua, collect the data from your variables, run the query (and optionally store them in a Lua cache) and process it all real-time, none-blocking and without any (extra) module.
Examples:
http://stackoverflow.com/questions/25955869/how-do-i-use-mysql-for-dynamic-doc-root-with-nginx
https://github.com/openresty/lua-resty-mysql
https://github.com/openresty/lua-nginx-module
---
nginx for Windows http://nginx-win.ecsds.eu/