Skip to main content

Database

HELIX provides a built-in database system through the Database module, backed by SQLite. This gives you persistent storage for player data, inventories, leaderboards, world state, and anything else that needs to survive a server restart.

Initializing the Database

The database file lives on your server and is created automatically when you first initialize. Call Database.Initialize once with the file path for your .db file.

Blueprint Initialize a SQLite databaseScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayDatabase InitializeFile Path"Saved/Database/my_world.db"

Creating Tables

Define your schema with standard SQL. Run this on server start so your tables are always ready.

Blueprint Create a players table with SQLScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayDatabase ExecuteSQL"CREATE TABLE IF NOT EXISTS players (...)"

CRUD Operations

Use Database.Execute for writes and Database.Select for reads. Parameterized queries keep your data safe from injection.

Blueprint CRUD operations: insert, update, select, deleteScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayDatabase ExecuteSQL"INSERT OR IGNORE INTO players ..."Param 1SteamIDParam 2PlayerNameDatabase ExecuteSQL"UPDATE players SET money = ?"Param 1500Param 2SteamIDDatabase SelectSQL"SELECT * FROM players WHERE id = ?"Param 1SteamIDRowsDatabase ExecuteSQL"DELETE FROM players WHERE id = ?"Param 1SteamID

Saving Player Data on Events

A common pattern is to save data when players disconnect and load it when they join.

Blueprint Save player position on disconnectScroll to zoom · Drag to pan · Drag nodes to move
Event PlayerDisconnectPlayerGet CharacterTargetCharacterGet Actor LocationTargetLocationDatabase ExecuteSQL"UPDATE players SET last_position = ?"PositionSteam ID
Blueprint Load player position on joinScroll to zoom · Drag to pan · Drag nodes to move
Event PlayerReadyPlayerDatabase SelectSQL"SELECT last_position FROM players WHERE id = ?"Steam IDRowsBranchConditionTrueFalseSet Actor LocationTargetNew Location

Async Operations

For operations that shouldn't block the game loop, use Database.ExecuteAsync and Database.SelectAsync. These run in the background and call a callback function when complete.

tip

Always use parameterized queries (? placeholders) instead of string concatenation. This prevents SQL injection and handles special characters automatically.