Digital Dive Studio: All products 50% off

Blueprint SQL/ORACLE/MySQL/ODBC Database Communicator

John Poole - Oct 26, 2018

Plugin that can execute database queries for a dedicated game server

  • Supported Platforms
  • Supported Engine Versions
    4.22 - 4.26
  • Download Type
    Engine Plugin
    This product contains a code plugin, complete with pre-built binaries and all its source code that integrates with Unreal Engine, which can be installed to an engine version of your choice then enabled on a per-project basis.

Works on Linux now! | REQUIRES FREE ODBC DRIVERS | Works on all common databases like SQL, MySql, Oracle etc... (You just have to chose the right ODBC driver)

This plugin can execute database queries within blueprints using ODBC. ODBC is a free, old school, stable, reliable, and cross-platform way to talk to a database. Most common database frameworks can use ODBC. SQL, MySql, Oracle, Azure, Amazon etc... can all be queried with this plugin. Blueprint usage is VERY similar to the widely used VaRest plugin. It utilizes UE4's FNonAbandonableTask to execute queries asynchronously without blocking the game thread.


NEVER put a database connection string in something you'll give to a stranger. I put mine in a config file only found on my Linux game servers. This plugin is for dedicated server side logic, or local database logic only.


Tutorial Video

Active Support: https://discord.gg/Sd4B2rm


About Me

I was the lead network engineer for a game studio using UE4. I've been a full-stack developer for 10 years. I specialize in making computers talk with SQL and .Net Core. I've built websites, email/fax/voice servers, matchmaking servers, torrent systems, and other network heavy logic. This plugin will improve overtime as I need it for my project https://www.thumpergames.com/world-of-pursuits.

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


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


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