Kris Krause .NET Meister

"If it is fast and ugly, they will use it and curse you; if it is slow, they will not use it."
- David Cheriton, The Art of Computer Systems Performance Analysis

Wednesday, April 08, 2009

MySql Connector .NET MySqlBulkLoader Example

Here is a MySqlBulkLoader example I quickly wrote to import 65,000 records into a mySql 5.1 database using the mySql Connector 5.2.5. And yes, its fast as snot (the lead programmer at my first programming job out of college invented the term).

.NET Reflector helped me figure out the follow details:

- the default FieldTerminator is "\t"
- the default LineTerminator is "\n"
- the default FieldQuotationCharacter is '\0'
- the .Load() method both opens and closes the connection

Also, the mySql documentation obviously helped to explain a lot including the "\r\n" Win32 line terminator in my example (I used Excel to export the CSV). The database user in this example needs "insert" permission.

Download the VB.NET, Sql, and CSV files here.

Labels: ,