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

#counters(sql_suffix = nil) ⇒ Object



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

def counters(sql_suffix = nil)
  @db.single_table('sync_snap_counters_table', sql_suffix)
end

#execute(sql) ⇒ Object



83
84
85
# File 'lib/aspera/sync/database.rb', line 83

def execute(sql)
  @db.execute(sql)
end

#file_info(sql_suffix = nil) ⇒ Object



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

def file_info(sql_suffix = nil)
  @db.full_table('sync_snapdb_table', sql_suffix)
end

#meta(sql_suffix = nil) ⇒ Object



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

def meta(sql_suffix = nil)
  @db.single_table('sync_snapmeta_table', sql_suffix)
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