Module: SQLite3::Pragmas
- Included in:
- Database
- Defined in:
- lib/sqlite3/pragmas.rb
Overview
This module is intended for inclusion solely by the Database class. It defines convenience methods for the various pragmas supported by SQLite3.
For a detailed description of these pragmas, see the SQLite3 documentation at sqlite.org/pragma.html.
Instance Method Summary collapse
-
#table_info(table, &block) ⇒ Object
:yields: row.
Instance Method Details
#table_info(table, &block) ⇒ Object
:yields: row
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sqlite3/pragmas.rb', line 42 def table_info(table, &block) # :yields: row columns, *rows = execute2("PRAGMA table_info(#{table})") needs_tweak_default = version_compare(driver.libversion, "3.3.7") > 0 result = [] unless block_given? rows.each do |row| new_row = {} columns.each_with_index do |name, index| new_row[name] = row[index] end tweak_default(new_row) if needs_tweak_default if block_given? yield new_row else result << new_row end end result end |