# Kafka pipeline that updates existing rows in a table

**URL:** <https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903>\
**Category:** Connectors and Pipelines\
**Tags:** pipelines\
**Created:** [June 21, 2023, 1:45pm UTC](https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903 "2023-06-21T13:45:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danabor](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@danabor](https://www.singlestore.com/forum/u/danabor)\
**Post date:** [June 21, 2023, 1:45pm UTC](https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903/1 "2023-06-21T13:45:13Z")

</div>

I have a Kafka topic that has messages about updates needed to be done for specific rows in a table (columnstore table)  
I want to create a pipeline that reads from this topic and update the table accordingly.  
example of a message:

```auto
{
"accountId ":"my-account",
"id":"my object",
"columnToUpdate":"some_column",
"valueToUpdate":"some_value",
"table":"my-table"
}

```

I want to be able in the end to execute some kind of update query in this style:

```auto
UPDATE $table SET $columnToUpdate = $valueToUpdate WHERE id = $id AND account_id = $accountId

```

I wanted to avoid using a loop in a stored procedure, from what I see it can take some time for a batch to be completed and I need those updates to be in a low latency since the message is consumed.

Thanks!

---

<div class="post-metadata">

**Author:** ![arjunsuhass](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@arjunsuhass](https://www.singlestore.com/forum/u/arjunsuhass)\
**Post date:** [June 22, 2023, 10:50pm UTC](https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903/2 "2023-06-22T22:50:02Z")

</div>

To Create a Kafka Pipeline for updating rows in a table based on messages from a topic,use a kafka connect JDBC sink connector. Configure the connector to consume messages and execute the update query dynamically, using fields like accountId, id, columnToUpdate, and valueToUpdate.

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [June 22, 2023, 10:52pm UTC](https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903/3 "2023-06-22T22:52:08Z")

</div>

I’d recommend using “[pipelines to stored procedures](https://docs.singlestore.com/managed-service/en/reference/sql-reference/pipelines-commands/create-pipeline-----into-procedure.html)” to do it. But if that doesn’t work or is not fast enough, then write an application that listens to the Kafka queue and reads messages, then runs the updates using a connection to SingleStore. The app could be multi-threaded or distributed, and use batching, if you need to drive very high throughput.

---

<div class="post-metadata">

**Author:** ![danabor](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/d/5f9b8f/32.png) [@danabor](https://www.singlestore.com/forum/u/danabor)\
**Post date:** [July 3, 2023, 7:08am UTC](https://www.singlestore.com/forum/t/kafka-pipeline-that-updates-existing-rows-in-a-table/6903/4 "2023-07-03T07:08:22Z")

</div>

Thanks for the replies, My question was more about how to construct a pipeline with a dynamic SQL according to the message I get from Kafka. for now, as I couldnt make the dynamic SQL to work I created a simple stored procedure to do that.
