Hi all,
I want to opensource my recently plugin project for UE4, here is the link:
Demo project: GitHub - dorgonman/HorizonDatabaseDemo
Document: HorizonDatabasePlugin: The mainpage documentation
The goal of this plugin is to provide ORM ability for database access.
Basically this Plugin is a wrapper for SOCI.
You will need enable exception and rtti to use this plugin.
*Note: I am still working on this plugin, some function name and usage may changed dramatically in later version.
Usage:
//============================create database==============================
pDB->DropTable(FHorizonTestDBTable1::StaticStruct()->GetName());
UHorizonTestDBTable1FunctionLibrary::CreateTable(pDB);
pTestCase->AddLogItem("ORMTestImplement CreateTable");
//============================test data===================================
FHorizonTestDBTable1BulkData bulkData;
FHorizonTestDBTable1 a0;
a0.Id = 0;
a0.TestString = "test a0";
a0.TestFloat = 1.333f;
a0.bTest1 = true;
FHorizonTestDBTable1 a1;
a1.Id = 1;
a1.TestString = "test a1";
a1.TestFloat = 2.3333f;
a1.bTest1 = false;
UHorizonTestDBTable1FunctionLibrary::AddBulkData(bulkData, a0);
UHorizonTestDBTable1FunctionLibrary::AddBulkData(bulkData, a1);
//auto insertSQL = AHorizonDatabase::GetInsertSQLUseStmt(pStruct, false);
pTestCase->AddLogItem("ORMTestImplement2 start insert row");
//============================insert row==================================
try {
UHorizonTestDBTable1FunctionLibrary::InsertBulkData(pDB, bulkData);
}
catch (std::exception& e) {
pTestCase->AddError(FString::Printf(TEXT("insertSQL exception: %s"), *FString(e.what())));
}
pTestCase->AddLogItem("end insert row");
//============================select single row==================================
{
auto data0 = UHorizonTestDBTable1FunctionLibrary::QueryData(pDB, "WHERE Id = 0");
pTestCase->TestEqual(TEXT("data0 == a0"), data0, a0);
auto data1 = UHorizonTestDBTable1FunctionLibrary::QueryData(pDB, "WHERE Id = 1");
pTestCase->TestEqual(TEXT("data1 == a1"), data1, a1);
}
Current Database backend implementation:
DB2: not implemented
Firebird: not implemented
MySQL: not implemented
ODBC: not implemented
Oracle: not implemented
PostgreSQL: not implemented
Sqlite3: implemented
Tested Engine veriosn: 4.13.
Tested Platform
Windows: tested.
MACOSX: Failed. need modify engine(Engine/Source/Programs/UnrealBuildTool/Mac/MacToolChain.cs) to enable rtti.
Android: tested, need cherry pick this commit and rebuild engine source code.
iOS: not tested, need cherry pick this commit and rebuild engine source code.
Linux: not tested.
Version History
- 0.2.0
- Refactor: Implement and adjust function for blueprint
- BugFix: Fix UTF8 type_conversion from db to FString
- 0.1.0
- NEW: First Version including core features.