Class: SQLiteServer2018
- Inherits:
-
Object
- Object
- SQLiteServer2018
- Defined in:
- lib/sqlite_server2018_plus.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
- #execute(dbfile, *args, &blk) ⇒ Object
- #exists?(dbfile) ⇒ Boolean
-
#initialize(nodes, debug: debug) ⇒ SQLiteServer2018
constructor
A new instance of SQLiteServer2018.
- #load_db(dbfile) ⇒ Object
- #ping ⇒ Object
- #query(*args, &blk) ⇒ Object
- #results_as_hash(*args) ⇒ Object
- #results_as_hash=(*args) ⇒ Object
- #table_info(*args) ⇒ Object
- #tables(dbfile) ⇒ Object
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
#nodes ⇒ Object
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
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 |
#ping ⇒ Object
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 |