Page 1 of 1

MySqlLoader and binary data

Posted: Tue 30 Jun 2020 15:57
by SquishyZA
I am using MySqlLoader to load a large number of rows into a table and the performance is awesome, but it does not seem to handle binary data properly.

I followed the example from the documentation.

Some pseudo code to illustrate:

Var loader = new MySqlLoader(...);
Loader.CreateColumns();
Loader.Open();
Foreach (var item in distinctItems)
{
loader.SetValue(“Size”, item.Size); // item.Size is a long
loader.SetValue(“Data”, item.Data); // item.Data is a byte[16]
loader.NextRow();
}
loader.Close();

What I observe:
1. Item.Data is truncated to 13 bytes on the first loop, most likely because it is not properly escaped. But I don’t see a way to escape it.
2. On the next loop the “Data” column is not updated so it properly inserts rows with new “Size” values but all the “Data” values matches the first row value

I tried representing item.Data as “X’[hex representation of item.Data]’” but that complained about the string being too long.

Any ideas would be appreciated.

Thank you

Re: MySqlLoader and binary data

Posted: Wed 01 Jul 2020 16:01
by SquishyZA
More information. So it is not actually truncating the binary data. It is storing the string ‘System.byte[]’ as bytes. I assume it is just doing a item.Data.ToString() type conversion.

Re: MySqlLoader and binary data

Posted: Tue 07 Jul 2020 17:34
by Shalex
Specify the datatype of your Data column.

If it is BINARY or VARBINARY, try using MySqlBinaryString:

Code: Select all

    loader.SetValue("Data", new MySqlBinaryString(item.Data));
Does this help?

Re: MySqlLoader and binary data

Posted: Wed 15 Jul 2020 16:03
by SquishyZA
Thank you, it did work.