Before You Start
- Keep your PostgreSQL server reachable from the machine running the game or editor.
- Know the host, database name, username, password, and port. The default PostgreSQL port is
5432. - Create the tables you want to read or update before calling them from Blueprint.
Blueprint Connection Steps
- Open the Blueprint that should talk to the database. This can be a level actor, GameInstance, subsystem wrapper, or UI controller.
- Add the PostgreSQL connection component from this product, or place the PostgreSQL connection actor in the level and reference it from your Blueprint.
- On
BeginPlay, a login button, or your own setup event, addMakePostgreSQLConnectionParams. - Fill
Server,Database,Username,Password, andPort. - If your server requires SSL or a timeout, add those values in the advanced connection fields.
- Pass the params into
CreateConnection. - Bind
OnConnectionStatusChangedandOnConnectionInvalidso your Blueprint can show success, failure, and reconnect UI.
Run a Select Query
- After the connection succeeds, call
SelectDataFromQuery. - Pass a normal SQL select string, such as:
SELECT id, player_name, score
FROM public.leaderboard
ORDER BY score DESC
LIMIT 10;
- Bind
OnQuerySelectStatusChanged. - When the event returns success, read the result from the returned data table or data rows.
- Use helper nodes such as
GetDataTableValue,GetDataRowValue, orFormatDataTableAsTextto display results in UMG.
Run an Insert, Update, or Delete
- Build your SQL statement in Blueprint.
- Call
UpdateDataFromQuery. - Bind
OnQueryUpdateStatusChangedto show whether the query finished successfully.
INSERT INTO public.leaderboard (player_name, score)
VALUES ('PlayerOne', 2500);
PostgreSQL Notes
- Use
ExtraParamsfor PostgreSQL-specific connection settings. - Keep SQL permissions limited to the actions your game needs.
- PostgreSQL supports image data through the PostgreSQL Blueprint image flow.