GameMaker (2.3)
Icon

AIO SQLite3 for GMS

Alex Ibrahim Ojea

You must be logged in to obtain assets

Description

Description updated 23-Feb-2022

The AIO SQLite3 for GMS contains multiple functions to work with SQLite3 DBs. The goal of this extension is to simplify the workflow on connecting to a SQLite3 DB and performing CRUD (Create, Read, Update, Delete) operations. Tested for the latest version of GMS.

MANUAL

You can see the manual for any of the published versions from this link

CURRENTLY SUPPORTED PLATFORMS

  • Windows: x64 and x86.
  • Ubuntu (Linux): ARM, ARM64 and x64.
  • Android: support for all architectures.

For additional support don't hesitate to contact me at [email protected] with the subject: "[AIO SQLite3 for GMS] your topic where you need help"

FUNCTIONS INCLUDED IN THE EXTENSION

The functions included in the extension are:

  • Test extension connection: Tests the connection with the extension. This should be done at the beginning before calling any other functions in the extension.
  • Enable / disable console reports: Enables / disables messages from the extension to appear on the output window of GMS. By default, it is enabled.
  • Memory used SQLite3: Shows the amount of memory currently in use by SQLite3 in bytes.
  • Memory peak SQLite3: Shows the peak memory used by SQLite3 in bytes since the last time the monitor was reset.
  • Last insert row ID: Gets the ID of the last inserted row in a DB.
  • If null: Checks if a given value is '(NULL)'. If the value is '(NULL)' it will be replaced with the provided value in the argument of the function.
  • Open DB: Opens a DB in the specified location in read or write mode. In write mode, if the DB doesn't exist in the specified location, it will create a new DB.
  • Close DB: Closes the connection with the DB and frees the memory.
  • Execute SQL: Executes and SQL statement against the indicated DB, useful for operations that don't require an extended callback information like the operators "DELETE", "INSERT" or "UPDATE".
  • Open RS: Executes the SQL statement retrieving a recordset. This function is intended to work with the "SELECT" operator. The RS will be a struct with important metadata like the columns or records retrieved after performing the select statement.
  • Move RS: Moves to the next record. The information of each column can be accessed by: MyRS.columnData[columnIWantToRetrieveDataFrom].
  • Close RS: Closes a RS freeing up all its associated memory.

EXAMPLE CODE

A basic example to perform a SELECT statement to a database located at the directory "C:/Users/aleja/Desktop/DLLTest/test.db", to the table "PERSON" and print all its returned values to the output console of GMS can be seen below:

if(f_AIO_SQLite3_testExtConnection()){//If the extension loaded OK.
    var _DBHandle=f_AIO_SQLite3_DBOpen("C:/Users/aleja/Desktop/DLLTest/test.db",true);//Open a DB in a path in read only mode.
    if(_DBHandle>=0){//If connection with DB ok.
        var _SQLString="SELECT * FROM PERSON ORDER BY ID;";//The SQL statement to be evaluated.
        var _RSHandle=f_AIO_SQLite3_RSOpen(_DBHandle,_SQLString);//Get the RS.
        if(is_struct(_RSHandle)){//A RS was returned.
            if(_RSHandle.records>0){//If we have records in our RS.
                //Get column names.
                for(var i=0;i<_RSHandle.columns;i++){//Loop through all the columns of the RS.
                    show_debug_message("COLUMN "+string(i)+ ": "+string(_RSHandle.columnNames[i]));//Show a debug message of all column names in the recordset.
                }
                //Get RS data.
                for(var i=0;i<_RSHandle.records;i++){//Loop through all the records of the RS.
                    f_AIO_SQLite3_RSMove(_RSHandle);//Move the recordset.
                    for(var j=0;j<_RSHandle.columns;j++){//Loop through all the columns of the RS.
                        show_debug_message("RS VAL [ROW "+string(i)+", COL "+string(j)+"]: "+string(f_AIO_SQLite3_ifNull(_RSHandle.columnData[j])));//Show a debug message of the value in the RS. If a value is '(NULL)' change it to '"'.
                    }
                }
            }
            f_AIO_SQLite3_RSClose(_RSHandle);//Close the RS (and perform memory free operations).
        }else{//There was some error getting the Recordset
            show_debug_message("RS FAILED");//Show a debug message.
        }
        f_AIO_SQLite3_DBClose(_DBHandle);//Close the DB conn (and perform memory free operations).
    }else{//Error connecting with the DB
        show_debug_message("DB CONN FAILED");//Show a debug message.
    }
}else{//The extension failed to load
    show_debug_message("THE EXTENSION FAILED TO LOAD");//Show a debug message.
}

End User Licence Agreement (EULA).

Age Rating: 4+

Version

GMS2.3 - Version 0.0.5. Published February 23, 2022

Included manual. It can be seen from the included files.

Loading, please wait

Package contents

Loading, please wait

What is the issue?

Loading, please wait