I need to update Clickhouse database with Python script (I use clickhouse_connect).
So, I need check conflicts before insert any data.
- In some tables I need just add new data.
For new data I generate manually ID’s, so I check last ID in database, make ID’s for new data and insert it into database by clickhouse_connect.get_client().insert_df(). - Table which I need update with auto generated ID’s if some row need to be changed and some just inserted.
First, I get ID’s which exists in new data and database and select data with differences.
This data should be altered.
For ID’s which not exists in database and just insert new data to database.
So how make update data in Clickhouse right? And how to make it with clickhouse_connect?
Is mutation the best way to make it?
ALTER TABLE [<database>.]<table> UPDATE <column> = <expression> WHERE <filter_expr>
1