USQLite Unreal Engine Plugin Documentation

Overview

USQLite is a powerful Unreal Engine plugin designed to handle runtime data persistence with SQLite databases, without requiring the developer to write SQL queries or deal with Blueprint complexity. It uses reflection to automatically generate SQL commands from object properties and supports complex features like multithreaded operations, data versioning, object reference serialization, and custom load screens.


๐ŸŽฌ >> QUICK TUTORIAL #1

๐ŸŽฌ >> QUICK TUTORIAL #2

๐Ÿ“ผ >> DOWNLOAD PROJECT HERE!



Key Features


Class Overview

USQLite_Settings

A configuration class to control default behavior of the SQLite system.

UPROPERTY(EditDefaultsOnly, config)
bool DeepLogs;

Enables verbose logging of SQL operations.


USQLite

The core class managing database operations and schema generation.

Properties

Blueprint Events

These events allow users to bind custom logic during save/load events.

Blueprint Functions

Command Queue API:

void DB_EnqueueSAVE(FString SQL);
void DB_EnqueueLOAD(FString SQL);

Immediate Execution API:

void DB_OBJ_ImmediateSAVE(UObject*);
void DB_OBJ_ImmediateLOAD(UObject*);

Update Column API: Updates single or arrays of:

Select API: Read values from columns or rows, supports all types as above.

Generate SQL API: Generate SQL queries for objects, actors, or components:

FString DB_GenerateSQL_Object_INSERT(UObject*);

Versioning API:

bool DB_SetVersion(FString);
bool DB_AddVersion(FString);
bool DB_HasVersion(FString);
TArray<FString> DB_GetVersionList();

Threading API:

void DB_GetThreadSafety(ESQLThreadSafety&, FSQLite_ThreadChanged);

Serializable Types

These are base classes designed to be extended to enable automatic SQL serialization.

Each includes overrideable events:

void DB_PrepareToSave(USQLite* Database, ESQLSaveMode Mode);
void DB_OnFinishLoad(USQLite* Database, bool Success);

Load Screen System

Customize user experience during save/load operations.

Modes:

Configuration:


Threaded Operations

Async workers automatically manage background database operations using Unrealโ€™s FNonAbandonableTask:

DBS_ExecuteQueue_Task
DBL_ExecuteQueue_Task
DBS_ImmediateSave_Task
DBL_ImmediateLoad_OBJ_Task

Example Use Cases


USQLite Usage Examples

๐Ÿ”น Saving and Loading Data

โœ… Blueprint Example

Save All Data

[Event Begin Play]
    โ†“
[Call Function: DB_Save]
    - Context: Self
    - Mode: SaveAll

Load All Data

[Event Begin Play]
    โ†“
[Call Function: DB_Load]
    - Context: Self

โœ… C++ Example

Save All Data

USQLite* MyDatabase = ...; // Reference to the database asset
MyDatabase->DB_Save(MyDatabase, ESQLSaveMode::SaveAll);

Load All Data

MyDatabase->DB_Load(MyDatabase);

๐Ÿ”น Saving an Object Immediately

โœ… Blueprint

[Call Function: DB_OBJ_ImmediateSAVE]
    - Object: TargetObject

โœ… C++

UObject* TargetObject = ...;
MyDatabase->DB_OBJ_ImmediateSAVE(TargetObject);

๐Ÿ”น Saving/Loading Actors & Components

โœ… Blueprint: Save Actor

[Call Function: DB_ACT_ImmediateSAVE]
    - Actor: TargetActor

โœ… C++

AActor* Actor = ...;
MyDatabase->DB_ACT_ImmediateSAVE(Actor);

๐Ÿ”น Custom Table Versioning

โœ… Blueprint

[Call Function: DB_SetVersion]
    - Table: "PlayerData_V2"

โœ… C++

bool success = MyDatabase->DB_SetVersion("PlayerData_V2");

๐Ÿ”น Custom SQL Generation

โœ… C++

FString SQL_Insert = MyDatabase->DB_GenerateSQL_Object_INSERT(MyObject);
FString SQL_Update = MyDatabase->DB_GenerateSQL_Object_UPDATE(MyObject);
FString SQL_Select = MyDatabase->DB_GenerateSQL_Object_SELECT(MyObject);

๐Ÿ”น Selecting & Updating Columns

โœ… Blueprint

[Call Function: DB_SELECT_Integer]
    - RowID: "Player_001"
    - ColumnName: "Health"
[Call Function: DB_UPDATE_Integer]
    - RowID: "Player_001"
    - ColumnName: "Health"
    - Value: 75

โœ… C++

int32 CurrentHealth = MyDatabase->DB_SELECT_Integer("Player_001", "Health");

ESQLResult Result = MyDatabase->DB_UPDATE_Integer("Player_001", "Health", 75);

๐Ÿ”น Handling Save/Load Events

โœ… Blueprint Events

Bind to:

โœ… C++ Overrides

void AMyActor::DB_OnBeginSave_Implementation(USQLite* Database)
{
    UE_LOG(LogTemp, Log, TEXT("Saving started"));
}

void AMyActor::DB_OnFinishLoad_Implementation(USQLite* Database, bool Success)
{
    if (Success)
    {
        UE_LOG(LogTemp, Log, TEXT("Loading completed successfully"));
    }
}

๐Ÿ”น Using Load Screens

โœ… Blueprint Settings

โœ… Runtime Behavior

When loading data, the system automatically shows the configured UI and tracks progress via:

[Call Function: DB_LaunchLoadScreen]

Summary

USQLite is designed to be easy to integrate with both Blueprints and C++, giving you powerful tools to persist data without dealing with SQL manually. Whether you're saving a simple player inventory or synchronizing thousands of object states across a streamed world, USQLite has you covered.