Before You Start
- Keep your MySQL or MariaDB server reachable from the machine running the game or editor.
- Know the host, schema/database name, username, password, and port. The default MySQL port is
3306. - Create a database user with only the permissions your Blueprint flow needs.
Blueprint Connection Steps
- Open the Blueprint that should own the database connection.
- Add the MySQL connection component from this product, or place the MySQL connection actor in the level and reference it.
- On your setup event, add
MakeMySQLConnectionParams. - Fill
Server,Database,Username,Password, andPort. - Pass the params into
CreateConnection. - Bind
OnConnectionStatusChanged,OnConnectionInvalid,OnQuerySelectStatusChanged, andOnQueryUpdateStatusChanged.
Run a Select Query
- Wait until
OnConnectionStatusChangedreports a valid connection. - Call
SelectDataFromQuerywith your SQL select statement.
SELECT id, display_name, coins
FROM players
ORDER BY coins DESC
LIMIT 10;
- Use the select status event to check for success or error text.
- Read values from the Blueprint data rows or table result.
Run an Insert, Update, or Delete
- Call
UpdateDataFromQueryfor statements that change data. - Bind the update status event and show a success or failure message in your UI.
UPDATE players
SET coins = coins + 100
WHERE id = 42;
Using the Dedicated MySQL Actor
- Place the MySQL connection actor if you need several live connections at once.
- Call
CreateNewConnectionand store the returnedConnectionID. - Pass that
ConnectionIDinto future select or update nodes. - Use
QueryIDwhen you need to match a completed event back to the UI request that started it. - Create a
MySQLConnectionOptionsasset when you need SSL, timeout, connect attribute, read-only, or multi-result settings editable outside the Blueprint graph.
MySQL Notes
- Use MySQL or MariaDB SQL syntax for queries.
- Close connections when the owning Blueprint is finished with them.
- Image and BLOB Blueprint nodes are not currently supported for MySQL or MariaDB in this package. Use Microsoft SQL Server if you need the image workflow today.