Unreal Engine Blueprint SQL/ORACLE/MySQL/ODBC Database Communicator UE7507
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.
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)
- Construct a Query UObject
- Promote the constructed Query UObject to a variable
- Bind the OnQueryFinished event
- 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
- Call ExecuteQueryAsync on the DatabaseQuery object
- A DatabaseQueryResult should be returned populated with results
- 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:
- ExecuteQueryAsync is called
- DatabaseQueryResult UObject is created on the game thread
- FNonAbandonableTask is created and begins to run async
- Inside of the async thread a connection is created to the SQL database
- QueryResultRowStructs are created for each result row and populated by ODBC SQLFetch()
- The FNonAbandonableTask returns the populated QueryResultStruct to the game thread and destroys
- The game thread converts the QueryResultStruct to the UDatabaseQueryResult created in step 2
- The blueprint friendly OnQueryFinished is broadcast with the populated UDatabaseQueryResult