Squirrel/Server/Functions/SQLite/sqlite open
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|sqlite_open}} {{RequiresModule|lu_sqlite|Modules/Squirrel/lu_sqlite}} This function opens an SQLite database or creates a new one. == Syntax == <code>UserPoint…') |
m (Fixed the example) |
||
Line 24: | Line 24: | ||
if ( cmd == "connectsql" ) | if ( cmd == "connectsql" ) | ||
{ | { | ||
− | local db = | + | local db = sqlite_open( "database.db" ); |
− | print( " | + | print( "Opening an SQLite database..." ); |
} | } | ||
Latest revision as of 16:58, 26 October 2010
Note: This function requires the external module lu_sqlite.
This function opens an SQLite database or creates a new one.
[edit] Syntax
UserPointer sqlite_open( string filename )
[edit] Arguments
- filename - This is the filename of the previously saved database or filename for the new database
[edit] Example
For a larger example, check the general SQLite database example from the wiki tutorials.
[edit] Example 2.
This example shows how to open to a database with a single command. The command loads a previously saved database from 'database.db', or if the file doesn't exist, creates a new database.
function onConsoleInput( cmd, text ) { if ( cmd == "connectsql" ) { local db = sqlite_open( "database.db" ); print( "Opening an SQLite database..." ); } return 1; }
[edit] Notes
The call onConsoleInput was used in in this example. More info about it in corresponding page.
[edit] Related Functions
These functions are provided by the official module lu_sqlite.