db connection + templating