Skip to main content

Database

The Database module provides a server-side SQLite database interface for persistent data storage. Use it to store player data, inventories, leaderboards, and any other persistent state. It provides both synchronous and asynchronous methods for executing queries and retrieving results.

Authority: Server -- Database operations can only be performed on the server.


Methods

MethodParametersReturn TypeAuthorityDescription
Database.Initializepath: stringvoidServerSets the file path for the SQLite database. Only needs to be called once.
Database.Executequery: string, params: tablebooleanServerRuns a SQL command (CREATE TABLE, INSERT, UPDATE, DELETE). Returns true on success.
Database.ExecuteAsyncquery: string, params: table, callback: functionvoidServerSame as Execute, but runs in the background. The callback receives a boolean success value.
Database.Selectquery: string, params: tabletableServerRuns a SELECT query and returns a list of rows. Each row has a .Columns table with the column values.
Database.SelectAsyncquery: string, params: table, callback: functionvoidServerSame as Select, but runs in the background. The callback receives the rows table.

Examples

Initializing the Database

Blueprint Initialize Database and Create TableScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayDatabase InitializePath"Saved/Database/data.db"Database ExecuteQuery"CREATE TABLE IF NOT EXISTS..."ParamsSuccess

CRUD Operations

Blueprint Database CRUD OperationsScroll to zoom · Drag to pan · Drag nodes to move
Custom Event DoCRUDDatabase ExecuteQuery"INSERT OR REPLACE INTO..."ParamsSuccessDatabase SelectQuery"SELECT * FROM PlayerData..."ParamsResults

Async Select

Blueprint Async Database SelectScroll to zoom · Drag to pan · Drag nodes to move
Custom Event DoAsyncQueryDatabase Select AsyncQuery"SELECT * FROM PlayerData"ParamsOn CompleteRowsFor Each LoopArrayLoop BodyCompletedArray ElementArray Index

warning

Never store database credentials in source code. Use the server configuration file to manage connection secrets.