Creating base connection between database and template