Skip to main content

HELIX Database

How to create and connect to a HELIX Database

To use HELIX database to store game components, a world has to be created in HUB. Go to CREATIONS -> WORLDS -> NEW

Fill the required information and then go to HOSTING from the left options and click on START DEDICATED HOSTING button and a dialog box with more options will be displayed.

In the next form, select the visibility of the server, a password, a description and set the max number of concurrent players but the most important is to activate the button next to Database as this will create a database inside the world allowing to save game information. Click on CONFIRM to continue.

⚠️ It's very important to activate the Database setting in order to have a working database.

After the server creation confirm, messages about starting the dedicated hosting will be shown on screen.

Having the Database started on the server, now can be accessed using the following code in Package-name\Server\Index.lua

\Server\Index.lua
local secret = Server.GetCustomSettings()
DB_IP = secret.DB_IP
DB_PORT = secret.DB_PORT
DB_USER = secret.DB_USER
DB_PASSWORD = secret.DB_PASSWORD
DB_NAME = secret.DB_NAME

PSQL = Database(
DatabaseEngine.PostgreSQL,
" hostaddr="
.. DB_IP
.. " port="
.. DB_PORT
.. " user="
.. DB_USER
.. " password="
.. DB_PASSWORD
.. " dbname="
.. DB_NAME
)

-- Creates a table
PSQL:Execute([[
CREATE TABLE IF NOT EXISTS test (
id INTEGER,
name VARCHAR(100)
)
]])

For more information about databases and code examples, please visit the Database page