pingcap / pingcap/docs-cn

使用MySqlBulkLoader报“don't support load data without local field”

Open
#9,846 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/question
Dominant language
Python
Stars
1.8k
Forks
1.2k
Avg merge
1d 16h
Merged PRs (30d)
31

Description

在使用MySqlBulkLoader进行批量插入时用出现下面错误:
MySql.Data.MySqlClient.MySqlException:“Load Data: don't support load data without local field”

目前是否支持MySqlBulkLoader?如果不支持,批量插入时是否有类似的方法?

实现代码如下:
try
{
conn.Open();
tran = conn.BeginTransaction();
MySqlBulkLoader bulk = new MySqlBulkLoader(conn)
{
FieldTerminator = ",",
FieldQuotationCharacter = '"',
EscapeCharacter = '"',
LineTerminator = "\r\n",
FileName = tmpPath,
NumberOfLinesToSkip = 0,
TableName = table.TableName,
};

                bulk.Columns.AddRange(table.Columns.Cast<DataColumn>().Select(colum => colum.ColumnName).ToList());
                insertCount = bulk.Load();
                tran.Commit();
            }
            catch (MySqlException ex)
            {
                if (tran != null) tran.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by checking the documentation for MySqlBulkLoader and the reported “don't support load data without local field” error against the provided C# example. Confirm whether the operation is supported and identify the documented bulk-insert alternative, then update the relevant Chinese documentation so the support status and recommended method are clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
databases, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.