Skip to content

Commit 127e694

Browse files
committed
Add drop tmp table
1 parent ad2804c commit 127e694

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Plugins/BotSharp.Plugin.ExcelHandler/Services/MySqlService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public IEnumerable<SqlContextOut> WriteExcelDataToDB(IWorkbook workbook)
9090
{
9191
var numTables = workbook.NumberOfSheets;
9292
var commandList = new List<SqlContextOut>();
93+
var state = _services.GetRequiredService<IConversationStateService>();
9394

9495
for (int sheetIdx = 0; sheetIdx < numTables; sheetIdx++)
9596
{
@@ -109,15 +110,17 @@ public IEnumerable<SqlContextOut> WriteExcelDataToDB(IWorkbook workbook)
109110
commandList.Add(commandResult);
110111
continue;
111112
}
112-
var (isInsertSuccess, insertMessage) = SqlInsertDataFn(sheet);
113113

114114
string table = $"{_database}.{_tableName}";
115+
state.SetState("tmp_table", table);
116+
117+
var (isInsertSuccess, insertMessage) = SqlInsertDataFn(sheet);
115118
string exampleData = GetInsertExample(table);
116119

117120
commandResult = new SqlContextOut
118121
{
119122
isSuccessful = isInsertSuccess,
120-
Message = $"{insertMessage}\r\nExample Data: {exampleData}",
123+
Message = $"{insertMessage}\r\nExample Data: {exampleData}. \r\n The remaining data contains different values. ",
121124
FileName = _currentFileName
122125
};
123126
commandList.Add(commandResult);

src/Plugins/BotSharp.Plugin.SqlDriver/Functions/ExecuteQueryFn.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public async Task<bool> Execute(RoleDialogModel message)
4141
_ => throw new NotImplementedException($"Database type {settings.DatabaseType} is not supported.")
4242
};
4343

44+
if (refinedArgs.SqlStatements.Length == 1 && refinedArgs.SqlStatements[0].StartsWith("DROP TABLE"))
45+
{
46+
message.Content = "Drop table successfully";
47+
return true;
48+
}
49+
4450
if (results.Count() == 0)
4551
{
4652
message.Content = "No record found";

0 commit comments

Comments
 (0)