A lightweight SQLite plugin for Unreal Engine that bundles and requires the sqlite-vec extension for vector similarity search.
It’s a code-only plugin (no Content assets) for running SQL and K-NN vector search inside UE (AI memory / embedding retrieval, etc.).
- Publisher: haozena
- Supported UE: 5.6 (Win64)
- Module:
SQLiteVecPlugin - Third-party: SQLiteCore (core, required), SQLiteVec (required; integrated with the plugin and loaded dynamically)
- Content:
"CanContainContent": false
- Close Unreal Editor.
- Copy the entire
SQLiteVecPlugin/folder to:- Recommended:
[YourProject]/Plugins/, or Engine/Plugins/(engine-wide install).
- Recommended:
- Verify required third-party files are included with the plugin:
Source/ThirdParty/Include/→sqlite3.h,sqlite3ext.h,sqlite-vec.hSource/ThirdParty/Bin/→SQLiteCore.dll,SQLiteVec.dlland their LICENSE files
- Launch UE → Edit > Plugins → enable SQLite Vector Embedding Database Plugin.
- On first package/build/run, the
Build.cscopies the needed DLLs to the runtime folder (usuallyYourProject/Binaries/Win64).
The plugin auto-registers/loads the
sqlite-vecextension inStartupModule. All nodes below are provided by this plugin.
- OpenDatabase(FilePath) → DBHandle (int32)
Example:Saved/SQLite/demo.db(created automatically if missing).
- Call CreateVecTable(DBHandle, OutError, TableName="items", Dim=1536).
This creates avec0virtual table; the vector column name isembedding(handled internally).
- Call InsertVecRow(DBHandle, TableName, RowId, VecData(float[]), OutError).
- The vector length must match the
Dimused at table creation; use PadFloatArray(InArray, TargetLength=Dim, FillValue=0.0) to pad/truncate if needed.
- The vector length must match the
- Call VectorQuery(DBHandle, TableName, QueryVec(float[]), K, OutResults, OutError).
OutResults : TArray<FVectorSearchResult>containsIdandDistance.
- CloseDatabase(DBHandle)
For regular SQL, use ExecuteSQL / QuerySQL.
#include "SQLiteVecBPLibrary.h"
int32 Handle = USQLiteVecBPLibrary::OpenDatabase(TEXT("Saved/SQLite/demo.db"));
FString Err;
bool Ok = false;
// A. Create vector table (note param order: DBHandle, OutError, TableName, Dim)
Ok = USQLiteVecBPLibrary::CreateVecTable(
Handle, Err, TEXT("items"), 1536);
// B. Insert a vector row
TArray<float> Vec; Vec.SetNum(1536);
// ... fill Vec ...
Ok = USQLiteVecBPLibrary::InsertVecRow(Handle, TEXT("items"), /*RowId=*/1, Vec, Err);
// C. K-NN query
TArray<float> Query; Query.SetNum(1536);
// ... fill Query ...
TArray<FVectorSearchResult> Results;
Ok = USQLiteVecBPLibrary::VectorQuery(Handle, TEXT("items"), Query, /*K=*/5, Results, Err);
// Close database
USQLiteVecBPLibrary::CloseDatabase(Handle);© 2025 haozena. All Rights Reserved.