Scripting/Squirrel/Functions/ConnectSQL: 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 |
m (→Usage) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== Usage == | == Usage == | ||
To use | To use SQLite you need to first download the sqlite plugin from [https://bitbucket.org/stormeus/0.4-sqlite/downloads[here]]. Once you have downloaded it place the plugin in your plugins folder and load the plugin in your server.cfg by adding a line in plugins that is for 32 bit users it is '''sqlite04rel32''' and for 64 bit users it is '''sqlite04rel64''' | ||
== Syntax == | == Syntax == | ||
To connect a database you need to use something like | To connect a database you need to use something like | ||
<source lang=javascript>function onScriptLoad() | |||
< | |||
{ | { | ||
db <- ConnectSQL( "Database.db" ); | db <- ConnectSQL( "Database.db" ); | ||
}</ | }</source> | ||
== Adding tables to your database == | == Adding tables to your database == | ||
You can add a table to your database by using the following function that is | You can add a table to your database by using the following function that is | ||
< | <source lang=javascript>QuerySQL( db, "CREATE TABLE IF NOT EXISTS YOUR_TABLE_NAME( COLUMN1 TEXT, COLUMN2 TEXT )" );</source> | ||
The Argument for your column can be used according to what you are storing/inserting to it. If you wished to insert/store a number you can change the TEXT to NUMERIC. If its a text you can use TEXT. | The Argument for your column can be used according to what you are storing/inserting to it. If you wished to insert/store a number you can change the TEXT to NUMERIC. If its a text you can use TEXT. | ||
== Related Functions == | |||
{{Scripting/Squirrel/Functions/SQLite Functions}} | |||
[[Category:Scripting/Squirrel/Functions/SQLite _Functions]] |
Latest revision as of 10:14, 26 April 2019
Usage
To use SQLite you need to first download the sqlite plugin from [here]. Once you have downloaded it place the plugin in your plugins folder and load the plugin in your server.cfg by adding a line in plugins that is for 32 bit users it is sqlite04rel32 and for 64 bit users it is sqlite04rel64
Syntax
To connect a database you need to use something like
function onScriptLoad()
{
db <- ConnectSQL( "Database.db" );
}
Adding tables to your database
You can add a table to your database by using the following function that is
QuerySQL( db, "CREATE TABLE IF NOT EXISTS YOUR_TABLE_NAME( COLUMN1 TEXT, COLUMN2 TEXT )" );
The Argument for your column can be used according to what you are storing/inserting to it. If you wished to insert/store a number you can change the TEXT to NUMERIC. If its a text you can use TEXT.