Scripting/Squirrel/Functions/QuerySQL

From Vice City Multiplayer
Revision as of 10:24, 26 April 2019 by Dracc (talk | contribs) (Add an example and description)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

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.

Related Functions