[Home] [Downloads] [Search] [Help/forum]

Database (SQLite)

MUSHclient from version 4.40 onwards has support for accessing SQLite 3 databases.


  • Databases are created and manipulated purely by script commands, generally intended to be inside plugins.

  • You can have any number of databases open at once. Each one has a name which is used by the script to refer to it.

  • Databases can be purely "in memory" by using the filename ":memory:".



General technique


  • Open the database with DatabaseOpen

  • Execute "action" SQL statements with DatabaseExec

  • To query data from the database:


    • Prepare an SQL statement with DatabasePrepare
    • Get column names with DatabaseColumnName or DatabaseColumnNames
    • Step through each row with DatabaseStep
    • Get column values with DatabaseColumnValue or DatabaseColumnValues
    • After all rows are extracted, finalize the statement with DatabaseFinalize


  • Close the database with DatabaseClose



For more information, see:


http://www.gammon.com.au/forum/?id=9262


You can also use the Lua sqlite3 interface to work on SQLite databases, in Lua only.


See Also ...

Topics

Lua SQLite (database) interface
Scripting

Functions

(DatabaseChanges) Returns a count of the changes to the database by the most recent SQL statement
(DatabaseClose) Closes an SQLite database
(DatabaseColumnName) Find the name of a specified column returned by an SQL statement
(DatabaseColumnNames) Return a table of all the columns returned by an SQL statement
(DatabaseColumns) Find how many columns will be returned by an SQL statement
(DatabaseColumnText) Returns the contents of an SQL column, as text
(DatabaseColumnType) Returns the type of data in an SQL column
(DatabaseColumnValue) Returns the contents of an SQL column, as text, float, integer, or null
(DatabaseColumnValues) Returns the contents of all the SQL columns after a step
(DatabaseError) Returns an English string describing the most recent SQL error
(DatabaseExec) Executes SQL code against an SQLite database
(DatabaseFinalize) Finalizes (wraps up) a previously-prepared SQL statement
(DatabaseGetField) Returns a single field from an SQL database
(DatabaseInfo) Returns information about a database
(DatabaseLastInsertRowid) Returns the most recently automatically allocated database key
(DatabaseList) Lists all databases
(DatabaseOpen) Opens an SQLite database
(DatabasePrepare) Prepares an SQL statement for execution
(DatabaseReset) Resets a previously-prepared SQL statement to the start
(DatabaseStep) Executes a previously-prepared SQL statement
(DatabaseTotalChanges) Returns a count of the total changes to the database

(Help topic: general=database)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]