Class: Nostrb::SQLite::Pragma
- Inherits:
-
Object
- Object
- Nostrb::SQLite::Pragma
- Defined in:
- lib/nostrb/sqlite.rb
Constant Summary collapse
- ENUM =
{ 'auto_vacuum' => %w[none full incremental], 'synchronous' => %w[off normal full], 'temp_store' => %w[default file memory], }
- RO =
%w[data_version freelist_count page_count]
- RW =
%w[application_id analysis_limit auto_vacuum automatic_index busy_timeout cache_size cache_spill cell_size_check checkpoint_fullfsync defer_foreign_keys encoding foreign_keys fullfsync hard_heap_limit ignore_check_constraints journal_mode journal_size_limit locking_mode max_page_count mmap_size page_size query_only read_uncommitted recursive_triggers reverse_unordered_selects secure_delete soft_heap_limit synchronous temp_store threads trusted_schema user_version wal_autocheckpoint]
- SCALAR =
(RO + RW).sort
- REPORT =
either no args (nil) or a single arg (symbol)
{ compile_options: nil, # list collation_list: nil, database_list: nil, function_list: nil, module_list: nil, pragma_list: nil, table_list: nil, index_list: :table_name, foreign_key_list: :table_name, # info index_info: :index_name, index_xinfo: :index_name, table_info: :table_name, table_xinfo: :table_name, }
- COMMAND =
either no args (nil) or an optional single arg (symbol)
{ # checks foreign_key_check: :optional, # table_name => report integrity_check: :optional, # table_name | num_errors => ok quick_check: :optional, # table_name | num_errors => ok # manipulation incremental_vacuum: :optional, # page_count => empty optimize: :optional, # mask => empty shrink_memory: nil, # empty wal_checkpoint: :optional, # PASSIVE | FULL | RESTART | TRUNCATE => row }
Instance Method Summary collapse
- #get(pragma) ⇒ Object
-
#initialize(db) ⇒ Pragma
constructor
A new instance of Pragma.
-
#list(pragma, arg = nil) ⇒ Object
just the rows.
-
#report(pragma, arg = nil) ⇒ Object
include a header row.
- #set(pragma, val) ⇒ Object
Constructor Details
#initialize(db) ⇒ Pragma
Returns a new instance of Pragma.
63 64 65 |
# File 'lib/nostrb/sqlite.rb', line 63 def initialize(db) @db = db end |
Instance Method Details
#get(pragma) ⇒ Object
67 68 69 |
# File 'lib/nostrb/sqlite.rb', line 67 def get(pragma) @db.execute("PRAGMA #{pragma}")[0][0] end |
#list(pragma, arg = nil) ⇒ Object
just the rows
77 78 79 80 81 82 83 |
# File 'lib/nostrb/sqlite.rb', line 77 def list(pragma, arg = nil) if arg.nil? @db.execute("PRAGMA #{pragma}") else @db.execute("PRAGMA #{pragma}(#{arg})") end end |
#report(pragma, arg = nil) ⇒ Object
include a header row
86 87 88 89 90 91 92 |
# File 'lib/nostrb/sqlite.rb', line 86 def report(pragma, arg = nil) if arg.nil? @db.execute2("PRAGMA #{pragma}") else @db.execute2("PRAGMA #{pragma}(#{arg})") end end |
#set(pragma, val) ⇒ Object
71 72 73 74 |
# File 'lib/nostrb/sqlite.rb', line 71 def set(pragma, val) @db.execute("PRAGMA #{pragma} = #{val}") get(pragma) end |