Skip to content

Commit 45c3c95

Browse files
specify line terminator as unix line endings when loading CSV to mysql
1 parent 044ed3b commit 45c3c95

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

Drivers/MySqlConnectorDriver.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ public string GetCopyFromImpl(Query query, string queryTextConstant)
219219
FieldTerminator = "{{csvDelimiter}}",
220220
FieldQuotationCharacter = '"',
221221
FieldQuotationOptional = true,
222-
NumberOfLinesToSkip = 1
222+
NumberOfLinesToSkip = 1,
223+
LineTerminator = "\n"
223224
};
224225
{{loaderVar}}.Columns.AddRange(new List<string> { {{loaderColumns}} });
225226
await {{loaderVar}}.LoadAsync();

examples/MySqlConnectorDapperExample/QuerySql.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ public async Task InsertMysqlTypesBatch(List<InsertMysqlTypesBatchArgs> args)
508508
FieldTerminator = ",",
509509
FieldQuotationCharacter = '"',
510510
FieldQuotationOptional = true,
511-
NumberOfLinesToSkip = 1
511+
NumberOfLinesToSkip = 1,
512+
LineTerminator = "\n"
512513
};
513514
loader.Columns.AddRange(new List<string> { "c_bit", "c_bool", "c_boolean", "c_tinyint", "c_smallint", "c_mediumint", "c_int", "c_integer", "c_bigint", "c_float", "c_numeric", "c_decimal", "c_dec", "c_fixed", "c_double", "c_double_precision", "c_char", "c_nchar", "c_national_char", "c_varchar", "c_tinytext", "c_mediumtext", "c_text", "c_longtext", "c_year", "c_date", "c_datetime", "c_timestamp", "c_binary", "c_varbinary", "c_tinyblob", "c_blob", "c_mediumblob", "c_longblob" });
514515
await loader.LoadAsync();

examples/MySqlConnectorDapperLegacyExample/QuerySql.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ public async Task InsertMysqlTypesBatch(List<InsertMysqlTypesBatchArgs> args)
509509
FieldTerminator = ",",
510510
FieldQuotationCharacter = '"',
511511
FieldQuotationOptional = true,
512-
NumberOfLinesToSkip = 1
512+
NumberOfLinesToSkip = 1,
513+
LineTerminator = "\n"
513514
};
514515
loader.Columns.AddRange(new List<string> { "c_bit", "c_bool", "c_boolean", "c_tinyint", "c_smallint", "c_mediumint", "c_int", "c_integer", "c_bigint", "c_float", "c_numeric", "c_decimal", "c_dec", "c_fixed", "c_double", "c_double_precision", "c_char", "c_nchar", "c_national_char", "c_varchar", "c_tinytext", "c_mediumtext", "c_text", "c_longtext", "c_year", "c_date", "c_datetime", "c_timestamp", "c_binary", "c_varbinary", "c_tinyblob", "c_blob", "c_mediumblob", "c_longblob" });
515516
await loader.LoadAsync();

examples/MySqlConnectorExample/QuerySql.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ public async Task InsertMysqlTypesBatch(List<InsertMysqlTypesBatchArgs> args)
451451
FieldTerminator = ",",
452452
FieldQuotationCharacter = '"',
453453
FieldQuotationOptional = true,
454-
NumberOfLinesToSkip = 1
454+
NumberOfLinesToSkip = 1,
455+
LineTerminator = "\n"
455456
};
456457
loader.Columns.AddRange(new List<string> { "c_bit", "c_bool", "c_boolean", "c_tinyint", "c_smallint", "c_mediumint", "c_int", "c_integer", "c_bigint", "c_float", "c_numeric", "c_decimal", "c_dec", "c_fixed", "c_double", "c_double_precision", "c_char", "c_nchar", "c_national_char", "c_varchar", "c_tinytext", "c_mediumtext", "c_text", "c_longtext", "c_year", "c_date", "c_datetime", "c_timestamp", "c_binary", "c_varbinary", "c_tinyblob", "c_blob", "c_mediumblob", "c_longblob" });
457458
await loader.LoadAsync();

examples/MySqlConnectorLegacyExample/QuerySql.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,8 @@ public async Task InsertMysqlTypesBatch(List<InsertMysqlTypesBatchArgs> args)
606606
FieldTerminator = ",",
607607
FieldQuotationCharacter = '"',
608608
FieldQuotationOptional = true,
609-
NumberOfLinesToSkip = 1
609+
NumberOfLinesToSkip = 1,
610+
LineTerminator = "\n"
610611
};
611612
loader.Columns.AddRange(new List<string> { "c_bit", "c_bool", "c_boolean", "c_tinyint", "c_smallint", "c_mediumint", "c_int", "c_integer", "c_bigint", "c_float", "c_numeric", "c_decimal", "c_dec", "c_fixed", "c_double", "c_double_precision", "c_char", "c_nchar", "c_national_char", "c_varchar", "c_tinytext", "c_mediumtext", "c_text", "c_longtext", "c_year", "c_date", "c_datetime", "c_timestamp", "c_binary", "c_varbinary", "c_tinyblob", "c_blob", "c_mediumblob", "c_longblob" });
612613
await loader.LoadAsync();

0 commit comments

Comments
 (0)