Scripting/Squirrel/Functions/QuerySQL: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary |
(Add an example and description) |
||
Line 1: | Line 1: | ||
This function will send a query to the database. | |||
== Syntax == | |||
<source lang=squirrel>QuerySQL(database, queryString);</source> | |||
== Arguments == | |||
* ''SQLiteDB'' '''database''' - The database to query | |||
* ''string'' '''queryString''' - The SQL query to send | |||
{{ | == Example == | ||
<source lang=squirrel> | |||
function onScriptLoad() { | |||
db <- ConnectSQL("scripts/keybinds.db"); | |||
if (!db) { | |||
print("ERROR: SQLite database file could not be opened"); | |||
} | |||
QuerySQL(db, "CREATE TABLE IF NOT EXISTS players(name TEXT, password TEXT, " + | |||
"level INTEGER, PRIMARY KEY(name,password));"); | |||
} | |||
</source> | |||
=== Notes === | |||
Calls [[onScriptLoad]], [[ConnectSQL]] and [[print]] were used in this example. More info about them in the corresponding pages. | |||
== Related Functions == | == Related Functions == |
Latest revision as of 10:24, 26 April 2019
This function will send a query to the database.
Syntax
QuerySQL(database, queryString);
Arguments
- SQLiteDB database - The database to query
- string queryString - The SQL query to send
Example
function onScriptLoad() {
db <- ConnectSQL("scripts/keybinds.db");
if (!db) {
print("ERROR: SQLite database file could not be opened");
}
QuerySQL(db, "CREATE TABLE IF NOT EXISTS players(name TEXT, password TEXT, " +
"level INTEGER, PRIMARY KEY(name,password));");
}
Notes
Calls onScriptLoad, ConnectSQL and print were used in this example. More info about them in the corresponding pages.