DB related Jinja files refactoring, fix syntax err