SQLiteDatabase.MultiUser

From Xojo Documentation

Revision as of 17:13, 12 February 2013 by PLefebvre (talk | contribs) (Created page with '{{PropertyBox | name=MultiUser | owner=SQLiteDatabase | ownertype=class | scope=public | type=Boolean | platform=all | newinversion=2011r1 }} {{Description |text = Enable…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Property (As Boolean )
aSQLiteDatabase.MultiUser = newBooleanValue
or
BooleanValue = aSQLiteDatabase.MultiUser

New in 2011r1

Supported for all project types and targets.

Enables the SQLite Write-Ahead Logging (WAL) mode which can improve performance of database writes. This is especially useful when multiple users are writing to the database, as can be the case with web applications.


Notes

If you want to use WAL, you need to set this property to True before connecting to the database.

WAL is faster than normal mode (called Journaled) because there is less disk writing. With WAL, a database change writes once to the write-ahead log. With Journaling, a database changes cause writes to a rollback file and to the original database file.

Although faster, WAL does have some limitations:

  • SQLite 3.7.0 or later is required to open WAL database
  • WAL database cannot be opened in read-only mode
  • Rolling back large transaction (over 100MB) can be slow
  • Two extra files are created (*.sqlite-wal and *.sqlite-shm) alongside the main database file

For more information about WAL, refer to the SQLite documentation: http://www.sqlite.org/draft/wal.html.


Example

This example sets MultiUser to True for a SQLite database:

Dim dbFile As GetFolderItem("MyDB.sqlite")

Dim db As New SQLiteDatabase
db.DatabaseFile = dbFile

db.MultiUser = True

If db.Connect Then
// Key was correct; DB is connected
MsgBox("Connected to database.")
Else
MsgBox("Connection error: " + db.ErrorMessage)
End If