UE4 操作 SQLite3
overview
蓝图操作SQLite3
打开数据链接
查询
Cpp 操作SQLite3
注意:外部模块调用插件内的接口,需要将插件中的接口导出。
class HISQLITE3_API USQLiteConnector {
}
USQLiteConnector* NewSQLiteConnector = NewObject<USQLiteConnector>();
FSQLiteReturnInfo ReturnInfo;
NewSQLiteConnector->Open(TEXT("Path:\\Test.sqlite"), ReturnInfo);
if (ReturnInfo.ReturnInfoType == ESQLiteReturnInfoType::SQLITE_OK) {
USQLiteResultor* Resultor;
NewSQLiteConnector->ExecuteWithRecordSet(TEXT("SELECT * FROM ElementsTable;"), Resultor, ReturnInfo);
{
TArray<FSQLiteColumnInfo> ColumnInfos;
Resultor->GetColumnInfos(ColumnInfos);
bool IsAtEnd;
FString str_value;
int32 int_value;
do {
for (auto colum : ColumnInfos)
{
switch (colum.DataType) {
case ESQLiteDataType::SQLITE_DT_STRING:
Resultor->GetString(colum.ColumnName, str_value);
break;
case ESQLiteDataType::SQLITE_DT_INT:
Resultor->GetInt(colum.ColumnName, int_value);
break;
default:
str_value = TEXT("");
break;
}
UE_LOG(LogTemp, Warning, TEXT("%s: %s"), *(colum.ColumnName), *str_value);
}
Resultor->MoveToNext();
Resultor->IsAtEnd(IsAtEnd);
} while ((!IsAtEnd));
}
}
参考
|