Module: SQLite3::Pragmas

Defined in:
lib/arjdbc/sqlite3/pragmas.rb

Overview

defines methods to de generate pragma statements

Constant Summary collapse

SYNCHRONOUS_MODES =

The enumeration of valid synchronous modes.

[["full", 2], ["normal", 1], ["off", 0]].freeze
TEMP_STORE_MODES =

The enumeration of valid temp store modes.

[["default", 0], ["file", 1], ["memory", 2]].freeze
AUTO_VACUUM_MODES =

The enumeration of valid auto vacuum modes.

[["none", 0], ["full", 1], ["incremental", 2]].freeze
JOURNAL_MODES =

The list of valid journaling modes.

[["delete"], ["truncate"], ["persist"], ["memory"], ["wal"], ["off"]].freeze
LOCKING_MODES =

The list of valid locking modes.

[["normal"], ["exclusive"]].freeze
ENCODINGS =

The list of valid encodings.

[["utf-8"], ["utf-16"], ["utf-16le"], ["utf-16be"]].freeze
WAL_CHECKPOINTS =

The list of valid WAL checkpoints.

[["passive"], ["full"], ["restart"], ["truncate"]].freeze

Class Method Summary collapse

Class Method Details

.cache_size(value) ⇒ Object

Set the local connection cache to 2000 pages https://www.sqlite.org/pragma.html#pragma_cache_size



67
68
69
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 67

def cache_size(value)
  "PRAGMA cache_size = #{value.to_i}"
end

.foreign_keys(value) ⇒ Object



31
32
33
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 31

def foreign_keys(value)
  gen_boolean_pragma(:foreign_keys, value)
end

.journal_mode(value) ⇒ Object

Journal mode WAL allows for greater concurrency (many readers + one writer) https://www.sqlite.org/pragma.html#pragma_journal_mode



37
38
39
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 37

def journal_mode(value)
  gen_enum_pragma(:journal_mode, value, JOURNAL_MODES)
end

.journal_size_limit(value) ⇒ Object

Impose a limit on the WAL file to prevent unlimited growth https://www.sqlite.org/pragma.html#pragma_journal_size_limit



61
62
63
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 61

def journal_size_limit(value)
  "PRAGMA journal_size_limit = #{value.to_i}"
end

.mmap_size(value) ⇒ Object

Set the global memory map so all processes can share some data https://www.sqlite.org/pragma.html#pragma_mmap_size https://www.sqlite.org/mmap.html



55
56
57
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 55

def mmap_size(value)
  "PRAGMA mmap_size = #{value.to_i}"
end

.synchronous(value) ⇒ Object

Set more relaxed level of database durability 2 = "FULL" (sync on every write), 1 = "NORMAL" (sync every 1000 written pages) and 0 = "NONE" https://www.sqlite.org/pragma.html#pragma_synchronous



44
45
46
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 44

def synchronous(value)
  gen_enum_pragma(:synchronous, value, SYNCHRONOUS_MODES)
end

.temp_store(value) ⇒ Object



48
49
50
# File 'lib/arjdbc/sqlite3/pragmas.rb', line 48

def temp_store(value)
  gen_enum_pragma(:temp_store, value, TEMP_STORE_MODES)
end