Squirrel/Server/Functions/SQLite/sqlite open

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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 = sqlite_connect( "database.db" );
+
           local db = sqlite_open( "database.db" );
 
            
 
            
           print( "Connecting to database..." );
+
           print( "Opening an SQLite database..." );
 
     }
 
     }
 
      
 
      

Latest revision as of 16:58, 26 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
Note: This function requires the external module lu_sqlite.

This function opens an SQLite database or creates a new one.

[edit] Syntax

  1. 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.

  1.  
  2. function onConsoleInput( cmd, text )
  3. {
  4. if ( cmd == "connectsql" )
  5. {
  6. local db = sqlite_open( "database.db" );
  7. print( "Opening an SQLite database..." );
  8. }
  9. return 1;
  10. }
  11.  

[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.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox