Blueprint SQL Database Communicator

Average Rating:  
X Rating Failed

Plugin that can execute SQL queries for a dedicated server

  • Supported Platforms
  • Supported Engine Versions
    4.20-4.21

Description


ONLY FOR DEDICATED SERVER SIDE LOGIC | REQUIRES ODBC DRIVERS

This is a plugin to execute SQL statements within blueprints. It utilizes UE4's FNonAbandonableTask to execute queries asynchronously without blocking the game thread.


Tutorial Video


How to create and execute a query in blueprints (See Blueprint Screenshot)

  1. Construct a Query UObject
  2. Promote the constructed Query UObject to a variable
  3. Bind the OnQueryFinished event
  4. Add a DatabaseRowModel struct variable. The DatabaseRowModel should contain the array of DatabaseColumnModels which contains the column name and variable type definitions. The StringBufferSize is only needed for string columns
  5. Call ExecuteQueryAsync on the DatabaseQuery object
  6. A DatabaseQueryResult should be returned populated with results
  7. You can GetValueAsString on a result column or cast it to it's variable type column to avoid converting it to a string


About Me

I was the lead network engineer for a game studio using UE4 for 2 years. I've been a fullstack developer for around 7 years. I specialize in SQL, .Net, and making computers talk. I've built websites, email/fax/voice servers, matchmaking servers, torrent systems, and other network heavy logic. This plugin is a step in a racing game that I'm developing and will improve overtime as I need it for my project. I may create a C++ only version for better performance in the future. C++ only would allow avoid the QueryResultStruct to UDatabaseQueryResult conversion.

Technical Details


Features

  •  Execute SQL statements within blueprints
  •  Queries are ran asynchronously in UE4's async thread pool
  •  Depending on query result size, hundreds of queries can execute at once without any noticeable lag on the game thread


Code Modules

  •  Core
  •  CoreUObject
  •  Engine


Behind the scenes:

  1. ExecuteQueryAsync is called
  2. DatabaseQueryResult UObject is created on the game thread
  3. FNonAbandonableTask is created and begins to run async
  4. Inside of the async thread a connection is created to the SQL database
  5. QueryResultRowStructs are created for each result row and populated by ODBC SQLFetch()
  6. The FNonAbandonableTask returns the populated QueryResultStruct to the game thread and destroys
  7. The game thread converts the QueryResultStruct to the UDatabaseQueryResult created in step 2
  8. The blueprint friendly OnQueryFinished is broadcast with the populated UDatabaseQueryResult

Comments

!

Previous Next
  • Edit
  • Preview
  • Help
Enter
Login to comment
X Report this Comment
Report
X Attention


close
X Edit this Comment
  • Edit
  • Preview
  • Help
Update
X Remove this Comment

Are you sure you want to remove this comment?

Remove
X Attention