Class: SqLite3Wrapper

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

Overview

A wrapper class that provides common API for Ruby and JRuby

Instance Method Summary collapse

Constructor Details

#initialize(db_path) ⇒ SqLite3Wrapper

Returns a new instance of SqLite3Wrapper.



13
14
15
# File 'lib/aspera/sync/database.rb', line 13

def initialize(db_path)
  @db_path = db_path
end

Instance Method Details

#execute(sql) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/aspera/sync/database.rb', line 18

def execute(sql)
  db = Sequel.connect("jdbc:sqlite:#{@db_path}")
  begin
    normalize_rows(db.fetch(sql).all)
  ensure
    db.disconnect
  end
end

#full_table(table_name) ⇒ Object



42
43
44
# File 'lib/aspera/sync/database.rb', line 42

def full_table(table_name)
  execute("SELECT * FROM #{table_name}")
end

#single_table(table_name) ⇒ Object

The table contains a single row



38
39
40
# File 'lib/aspera/sync/database.rb', line 38

def single_table(table_name)
  execute("SELECT * FROM #{table_name} LIMIT 1").first
end