DocsDataBasesPostgreSQL

PostgreSQL

Blueprint setup for PostgreSQL runtime queries in Unreal Engine

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

  1. Open the Blueprint that should talk to the database. This can be a level actor, GameInstance, subsystem wrapper, or UI controller.
  2. Add the PostgreSQL connection component from this product, or place the PostgreSQL connection actor in the level and reference it from your Blueprint.
  3. On BeginPlay, a login button, or your own setup event, add MakePostgreSQLConnectionParams.
  4. Fill Server, Database, Username, Password, and Port.
  5. If your server requires SSL or a timeout, add those values in the advanced connection fields.
  6. Pass the params into CreateConnection.
  7. Bind OnConnectionStatusChanged and OnConnectionInvalid so your Blueprint can show success, failure, and reconnect UI.

Run a Select Query

  1. After the connection succeeds, call SelectDataFromQuery.
  2. Pass a normal SQL select string, such as:
SELECT id, player_name, score
FROM public.leaderboard
ORDER BY score DESC
LIMIT 10;
  1. Bind OnQuerySelectStatusChanged.
  2. When the event returns success, read the result from the returned data table or data rows.
  3. Use helper nodes such as GetDataTableValue, GetDataRowValue, or FormatDataTableAsText to display results in UMG.

Run an Insert, Update, or Delete

  1. Build your SQL statement in Blueprint.
  2. Call UpdateDataFromQuery.
  3. Bind OnQueryUpdateStatusChanged to show whether the query finished successfully.
INSERT INTO public.leaderboard (player_name, score)
VALUES ('PlayerOne', 2500);

PostgreSQL Notes

  • Use ExtraParams for PostgreSQL-specific connection settings.
  • Keep SQL permissions limited to the actions your game needs.
  • PostgreSQL supports image data through the PostgreSQL Blueprint image flow.
DataBases - PostgreSQL | Athian Games