Class: SQLiteServer2018

Inherits:
Object
  • Object
show all
Defined in:
lib/sqlite_server2018_plus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes, debug: debug) ⇒ SQLiteServer2018

Returns a new instance of SQLiteServer2018.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sqlite_server2018_plus.rb', line 18

def initialize(nodes, debug: debug)
  
  @nodes, @debug = nodes, debug
  

  if (nodes & Socket.ip_address_list.map(&:ip_address)).any? then
    raise SQLiteServer2018PlusException, 
        'Cannot use host IP address in node list'
  end
  
  @failcount = 0
  @db = fetch_server(nodes.first)
  
end

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes.



16
17
18
# File 'lib/sqlite_server2018_plus.rb', line 16

def nodes
  @nodes
end

Instance Method Details

#execute(dbfile, *args, &blk) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sqlite_server2018_plus.rb', line 33

def execute(dbfile, *args, &blk)
  
  puts 'inside SQLiteServer2018::execute args: ' + args.inspect if @debug
  
  if block_given? then
    a = db_op { @db.execute(dbfile, *args)  }
    a.each(&blk)
  else
    db_op { @db.execute dbfile, *args, &blk }
  end

end

#exists?(dbfile) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
# File 'lib/sqlite_server2018_plus.rb', line 46

def exists?(dbfile)
  
  puts 'inside SQLiteServer2018::exists?' if @debug
  db_op { @db.exists? dbfile }
      
end

#load_db(dbfile) ⇒ Object



53
54
55
56
57
58
# File 'lib/sqlite_server2018_plus.rb', line 53

def load_db(dbfile)    
      
  puts 'inside SQLiteServer2018::load' if @debug
  db_op { @db.load_db dbfile }
  
end

#pingObject



60
61
62
# File 'lib/sqlite_server2018_plus.rb', line 60

def ping()
  db_op { @db.ping }
end

#query(*args, &blk) ⇒ Object



64
65
66
67
68
69
# File 'lib/sqlite_server2018_plus.rb', line 64

def query(*args, &blk)
  
  puts 'inside SQLiteServer2018::query args: ' + args.inspect if @debug
  db_op { @db.query *args, &blk }
  
end

#results_as_hash(*args) ⇒ Object



71
72
73
# File 'lib/sqlite_server2018_plus.rb', line 71

def results_as_hash(*args)    
  db_op { @db.results_as_hash *args }
end

#results_as_hash=(*args) ⇒ Object



75
76
77
# File 'lib/sqlite_server2018_plus.rb', line 75

def results_as_hash=(*args)
  db_op { @db.results_as_hash = *args }
end

#table_info(*args) ⇒ Object



79
80
81
# File 'lib/sqlite_server2018_plus.rb', line 79

def table_info(*args)
  db_op { @db.table_info *args }
end

#tables(dbfile) ⇒ Object



83
84
85
# File 'lib/sqlite_server2018_plus.rb', line 83

def tables(dbfile)    
  db_op { @db.tables dbfile }        
end