From af32409f7925fe18aef2eaf823227cd95f049664 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Sun, 6 Oct 2024 19:50:51 +0200 Subject: [PATCH] BulkResponse: Add documentation --- docs/query.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/query.rst b/docs/query.rst index a408f369..5a0b44b6 100644 --- a/docs/query.rst +++ b/docs/query.rst @@ -76,6 +76,20 @@ for every tuple. This dictionary always has a ``rowcount`` key, indicating how many rows were inserted. If an error occurs, the ``rowcount`` value is ``-2``, and the dictionary may additionally have an ``error_message`` key. +The package includes a helper utility ``BulkResponse`` that supports parsing +such responses to bulk operation requests. It works like this:: + + from crate.client.result import BulkResponse + + result = cursor.executemany(statement, records) + bulk_response = BulkResponse(records, result) + +It provides properties ``failed_records``, ``record_count``, ``success_count``, +and ``failed_count``. ``failed_records`` will provide information which records +of the bulk operation failed to succeed, by evaluating ``{'rowcount': -2}`` +items, and matching them against submitted records. + + .. _selects: Selecting data