# How do I call C++ from a Blueprint project to store variables in a database?

**URL:** <https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [January 30, 2015, 10:36pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517 "2015-01-30T22:36:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arveum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arveum](https://forums.unrealengine.com/u/Arveum)\
**Post date:** [January 30, 2015, 10:36pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/1 "2015-01-30T22:36:12Z")

</div>

Hello **AnswerHub** ,

Me and my brother are developing a game that has to store user data into a database. For example their level, exp amount, amount of health, things like that. We both however come from a webdevelopment background and have no experience in C++ whatsoever, which is why we went with blueprints.

I’ve searched across all of the interwebz but I haven’t been able to find out how to ‘do a call to C++’ from a blueprint to make a connection to something like MySQL. Is something like this even possible to do, and if so… how?

If this isn’t possible, could you then perhaps supply me with alternatives? I would really like to avoid having to learn C++ from scratch.

Thanks in advance,

Kevin

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [January 30, 2015, 10:43pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/2 "2015-01-30T22:43:03Z")

</div>

You likely shouldn’t be connecting to the DB directly through C++ to begin with. It’s likely best to setup a PHP API/REST to handle DB communication. Doing that you should be able to use the Blueprint nodes for communicating via PHP to store info in MySQL.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 30, 2015, 11:09pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/3 "2015-01-30T23:09:55Z")

</div>

You mean connecting to DB from client-side, server side is safe… atleast same as safe as PHP 😛

---

<div class="post-metadata">

**Author:** ![HailstoneRyan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HailstoneRyan](https://forums.unrealengine.com/u/HailstoneRyan)\
**Post date:** [January 30, 2015, 11:14pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/4 "2015-01-30T23:14:19Z")

</div>

If the server executable is the only thing that has access to this code then sure.

In that case writing a plugin for UE4 that can interact with the MySQL C++ driver. With that said the MySQL C++ driver is blocking and as such any communication with the DB needs to be done in a thread so that it doesn’t cause the game to stop and wait.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 30, 2015, 11:15pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/5 "2015-01-30T23:15:06Z")

</div>

You can’t call external native code (because at that point they aren’t C++ anymore) from blueprint, instead you need to write BlueprintCallable C++ code that will bind some external library to blueprint. I know some people been interested in DB support in UE4 so you might find some ready plugins

---

<div class="post-metadata">

**Author:** ![Duncan\_Dam](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Duncan\_Dam](https://forums.unrealengine.com/u/Duncan_Dam)\
**Post date:** [January 31, 2015, 1:35am UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/6 "2015-01-31T01:35:14Z")

</div>

Try out this plugin, we use this for our database right now. Everything is in blueprint.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Arveum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arveum](https://forums.unrealengine.com/u/Arveum)\
**Post date:** [January 31, 2015, 12:27pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/7 "2015-01-31T12:27:42Z")

</div>

Thanks alot for that plugin!

---

<div class="post-metadata">

**Author:** ![Arveum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arveum](https://forums.unrealengine.com/u/Arveum)\
**Post date:** [January 31, 2015, 12:28pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/8 "2015-01-31T12:28:50Z")

</div>

Thanks for taking the time to reply, Duncan supplied me with a plugin like you’ve mentioned.

---

<div class="post-metadata">

**Author:** ![Arveum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arveum](https://forums.unrealengine.com/u/Arveum)\
**Post date:** [January 31, 2015, 12:30pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/9 "2015-01-31T12:30:34Z")

</div>

Thanks for taking the time to reply, do you perhaps have a link I can visit so I can learn how to setup communication with a PHP API/REST via Blueprints?

---

<div class="post-metadata">

**Author:** ![Arveum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Arveum](https://forums.unrealengine.com/u/Arveum)\
**Post date:** [January 31, 2015, 9:07pm UTC](https://forums.unrealengine.com/t/how-do-i-call-c-from-a-blueprint-project-to-store-variables-in-a-database/305517/10 "2015-01-31T21:07:17Z")

</div>

I’m trying to install this on UE 4.6.1, says the build fails because plugin was made with different version of engine. I’ve taken a look and it seems its compatible with 4.6.0 only.

Am I missing something, is there a way around this, and if not, is there an alternative?
