Using NetDB with C++
C++ support is currently on a best-effort basis.
While NetDB was created as a Blueprint-oriented plugin, most of its functionality is still readily accessible from C++. Before proceeding, do be advised that this isn’t an officially supported use case, meaning that we might not be able to resolve all of the bugs that you might encounter. Nonetheless, we encourage you to give it a try and we might still be able to give you some pointers if you run into issues.
First of all, there is a C++ example project that demonstrates basic operations such as connecting to a database, running queries and some pointers on how to run these operations asynchronously. The example project can be downloaded from here.
The majority of this example has been implemented in NetDBCPPGameModeBase.h and NetDBCPPGameModeBase.cpp. There are quite a few comments that try to explain the what/how/why of the code, with two main comment categories:
- Multiline
/* ... */comments: these are a very high-level description of what a section does - Single-line
//comments: these provide some more details where deemed necessary.
In this example project, we made use of the following example database:

The key takeaways of the example project, and using NetDB in your C++ project, are as follows:
- To include NetDB's code, add
NetDBPluginto your.Build.cs'sPrivateDependencyModuleNames. - Most of the functionality that is compatible with C++ is stored in the
UNetDBPluginBPLibraryclass (#include "NetDBPluginBPLibrary.h"). - Most of the functions in this class are static/procedural - simply call them as such, so e.g.
UNetDBPluginBPLibrary::PostgresConnect(...);. - To this functionality asynchronously, use the
AsyncTaskfunction with a low-priority/background priority. - If your table and/or column names contain upper-case characters, please make sure to wrap them in
"(you'll need to escape the":/"; for further information, see: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS)