Class: Libsql::Connection

Inherits:
Object
  • Object
show all
Includes:
Prepareable
Defined in:
lib/libsql.rb

Instance Method Summary collapse

Methods included from Prepareable

#execute, #query

Constructor Details

#initialize(inner) ⇒ Connection

Returns a new instance of Connection.



375
376
377
# File 'lib/libsql.rb', line 375

def initialize(inner)
  @inner = inner
end

Instance Method Details

#closeObject



404
# File 'lib/libsql.rb', line 404

def close = @inner.deinit

#execute_batch(sql) ⇒ Object



402
# File 'lib/libsql.rb', line 402

def execute_batch(sql) = @inner.execute_batch(sql)

#prepare(sql) ⇒ Object



394
395
396
397
398
399
400
# File 'lib/libsql.rb', line 394

def prepare(sql)
  stmt = Statement.new @inner.prepare sql

  return stmt unless block_given?

  begin yield stmt ensure stmt.close end
end

#transactionObject



379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/libsql.rb', line 379

def transaction
  tx = Transaction.new @inner.transaction
  return tx unless block_given?

  abort = false
  begin
    yield self
  rescue StandardError
    abort = true
    raise
  ensure
    abort and tx.rollback or tx.commit
  end
end