Safe insert in the database (try except and session rollback)