Skip to content

Commit

Permalink
test2
Browse files Browse the repository at this point in the history
  • Loading branch information
area363 committed Jun 10, 2024
1 parent e9f0cca commit 490ae22
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ string mysqlDatabase
// Check if intervalCount has hit 5, if so reset it and continue
if (intervalCount == 5)
{
intervalCount = 0;
continue;
break;
}

var avatarAddress = new Address(avatar);
Expand Down Expand Up @@ -489,6 +488,8 @@ private void BulkInsert(
{
DateTimeOffset start = DateTimeOffset.Now;
Console.WriteLine($"Start bulk insert to {tableName}.");
var target_table = tableName;
var temp_table = tableName + "_temp";
MySqlBulkLoader loader = new MySqlBulkLoader(connection)
{
TableName = tableName,
Expand All @@ -497,11 +498,20 @@ private void BulkInsert(
LineTerminator = "\n",
FieldTerminator = ";",
Local = true,
ConflictOption = MySqlBulkLoaderConflictOption.Replace,
ConflictOption = MySqlBulkLoaderConflictOption.Replace
};

loader.Load();
Console.WriteLine($"Bulk load to {tableName} complete.");

// Insert data from temporary table to target table
string insertSql = $"INSERT INTO {target_table} (Address, AgentAddress, Name, AvatarLevel, TitleId, ArmorId, Cp, Timestamp) SELECT Address, AgentAddress, Name, AvatarLevel, TitleId, ArmorId, Cp, Timestamp FROM {temp_table} ON DUPLICATE KEY UPDATE Cp = VALUES(Cp), Timestamp = VALUES(Timestamp);";

using (MySqlCommand command = new MySqlCommand(insertSql, connection))
{
command.ExecuteNonQuery();
}

DateTimeOffset end = DateTimeOffset.Now;
Console.WriteLine("Time elapsed: {0}", end - start);
}
Expand Down

0 comments on commit 490ae22

Please sign in to comment.