writes the rectangles in the database (NEED TEST)