Class: Aspera::Sync::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/sync/database.rb

Overview

Access async sqlite database

Instance Method Summary collapse

Constructor Details

#initialize(db_path) ⇒ Database

Returns a new instance of Database.



57
58
59
# File 'lib/aspera/sync/database.rb', line 57

def initialize(db_path)
  @db = SqLite3Wrapper.new(db_path)
end

Instance Method Details

#countersObject



75
76
77
# File 'lib/aspera/sync/database.rb', line 75

def counters
  @db.single_table('sync_snap_counters_table')
end

#file_infoObject



79
80
81
# File 'lib/aspera/sync/database.rb', line 79

def file_info
  @db.full_table('sync_snapdb_table')
end

#metaObject



71
72
73
# File 'lib/aspera/sync/database.rb', line 71

def meta
  @db.single_table('sync_snapmeta_table')
end

#overviewObject



61
62
63
64
65
66
67
68
69
# File 'lib/aspera/sync/database.rb', line 61

def overview
  tables = @db.execute("SELECT name FROM sqlite_master WHERE type='table';")
  tables.flat_map do |table_row|
    table_name = table_row['name']
    @db.execute("PRAGMA table_info(#{table_name});").map do |col|
      {'table' => table_name}.merge(col)
    end
  end
end