PostgreSQL Support

Does Defold have PostgreSQL support? I can’t seem to find any articles or examples of how a PostgreSQL database has been used for a project.

Has anyone been able to successfully integrate a PostgreSQL database into their project?

Defold itself does not support this as we want to keep the core engine small for all users. This kinds of integration is usually done as an extension of some kind. You can build an extension in C++, include an existing PostgreSQL library and expose required functions to Lua.

Libpq seems to be exactly the kind of library you’d like to wrap in a Defold extension: PostgreSQL: Documentation: 13: Chapter 33. libpq — C Library

2 Likes

I didn’t think about that. I come from a data science background, so I start by thinking about how I am going to record user data and activities completed within an application/game.

Ah, I understand. It is not very common to use a traditional database to store user data, game state etc. There are usually services that do this, such as Google Play Game Services on Android, Apple Game Center on iOS, Steam for desktop, or Nakama, PlayFab or some other service for cross platform online cloud save, achievements etc

3 Likes

That’s good to know. I appreciate the advice!

Since you didn’t mention storing the data online, I assume storing it locally on the device is ok.

Then we have the sys.save() function, which lets you save a table of data. And, similarly, you can use sys.load() to retrieve it.

3 Likes