Class: RDBr::Catalog::Sqlite

Inherits:
Reader
  • Object
show all
Defined in:
lib/rdbr/catalog/sqlite.rb

Constant Summary collapse

FOREIGN_KEY_ACTIONS =
{
  'NO ACTION' => :no_action,
  'RESTRICT' => :restrict,
  'CASCADE' => :cascade,
  'SET NULL' => :set_null,
  'SET DEFAULT' => :set_default
}.freeze
TYPE_MAPPINGS =
{
  /BOOL/ => :boolean, /JSON/ => :json, /DATETIME|TIMESTAMP/ => :timestamp, /DATE/ => :date,
  /TIME/ => :time, /INT/ => :int8, /CHAR|CLOB|TEXT/ => :text, /REAL|FLOA|DOUB/ => :float8,
  /\A\z|BLOB/ => :blob
}.freeze

Instance Method Summary collapse

Methods inherited from Reader

for, #initialize

Constructor Details

This class inherits a constructor from RDBr::Catalog::Reader

Instance Method Details

#readObject



17
18
19
20
21
# File 'lib/rdbr/catalog/sqlite.rb', line 17

def read
  database_rows = connection.select_all('PRAGMA database_list')
  namespaces = database_rows.filter_map{|row| build_namespace(row.fetch('name')) }
  Metadata::Database.new(name: database_name(database_rows), adapter: :sqlite, namespaces: namespaces)
end