Batch Insert/Delete by API?


#1

I have more than 5000 records from single table of MYSQL.
And I tried to insert each of them into Xibo Dataset by API.
(https://xibo.org.uk/manual-tempel/api/#/dataset/dataSetDataAdd)

I found that it needs over 5 minutes to insert all of them. Moreover I cannot clear all rows or a range of rows.
In order to clear all rows without delete the dataset, I have to get the first and last rows’s id and set a for loop to delete them one by one.

As I add row by Postman, I used form-data and it seems only 1 row can be added per request.
image

Here’s part of my ASP.NET Application, I used for loop to insert these data.

for (int i = 0; i < dt.Rows.Count; i++)
{
      //Use 
      Task.Run(async () => { await AddRowAsync(dataSetId, formdata); }).Wait();
}

Is there any way I can perform batch insert and also batch delete by API?
For example, modifying the API header, parameters?


#2

You can batch insert via CSV, and overwrite the existing data in that same operation. So you’d just send in the dataset as you want it to appear all in one call:


#3

Inserting CSV seems to be a good idea.
But I am wondering if there’s too many changes on the dataset.
Will some data be inserted to the dataset instead of overwriting?


#4

You choose as a parameter to your call.

Either the CSV you upload replaces the dataset in its entirety, or it is appended to it. There’s no half-way option.


#5

I see your point, thank you! :grinning: