Added database commit to try except