Skip to content

Sqlite API

Nenkai edited this page Jul 14, 2024 · 3 revisions

Warning

GT6 and above.

< MSqlite Reference Class >

Open Database

var sqlite = pdistd::MSqlite();
sqlite.open(path);

// You can also use pdistd::MSqlite(path, buffer_size, flags, salsa_key); // 

Execute Query

var res = SQLITE.execute0(sql); // No params
res = SQLITE.execute(sql, params); // With params - '?' characters are replaced with param names

if (res == SQLITE_OK)
{
    // ...
} 

Query Rows

// Example:
var rows = sqlite.executeQuery("SELECT * FROM COURSE ORDER BY ID");
foreach (var row in rows)
{
    var [col1, col2, ...] = row;
}

// Query all values of 1 column
var column_values = sqlite.executeQuery1C(sql);

// Query one column of one row
var cell = sqlite.executeQuery1R1C(sql);

Row Count

var row_count = sqlite.count(sql, params);

Query (Objects with attribute)

These return STRecord

var rows = sqlite.query(sql, params);
foreach (var row in res)
{
   var col_value = row.col;
}

// List
var list = sqlite.queryList(sql, params);

// One row
var row = sqlite.query1(sql, params);

Transaction

sqlite.begin();

// ...

sqlite.commit();

Execute Transaction

sqlite.executeTransaction(sql_query_array) // Array<String, Array<Object>>
Clone this wiki locally