Fixed catching sqlalchemy exception in connection to database and adding new record