Class: Libsql::Connection
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #execute_batch(sql) ⇒ Object
-
#initialize(inner) ⇒ Connection
constructor
A new instance of Connection.
- #last_inserted_id ⇒ Object
- #prepare(sql) ⇒ Object
- #total_changes ⇒ Object
- #transaction ⇒ Object
Methods included from Prepareable
Constructor Details
#initialize(inner) ⇒ Connection
Returns a new instance of Connection.
487 488 489 |
# File 'lib/libsql.rb', line 487 def initialize(inner) @inner = inner end |
Instance Method Details
#close ⇒ Object
532 533 534 535 536 537 |
# File 'lib/libsql.rb', line 532 def close raise ClosedException if closed? @inner.deinit @inner = nil end |
#closed? ⇒ Boolean
539 540 541 |
# File 'lib/libsql.rb', line 539 def closed? @inner.nil? end |
#execute_batch(sql) ⇒ Object
530 |
# File 'lib/libsql.rb', line 530 def execute_batch(sql) = @inner.execute_batch(sql) |
#last_inserted_id ⇒ Object
514 515 516 517 518 |
# File 'lib/libsql.rb', line 514 def last_inserted_id raise ClosedException if closed? @inner.info[:last_inserted_id] end |
#prepare(sql) ⇒ Object
520 521 522 523 524 525 526 527 528 |
# File 'lib/libsql.rb', line 520 def prepare(sql) raise ClosedException if closed? stmt = Statement.new @inner.prepare sql return stmt unless block_given? begin yield stmt ensure stmt.close end end |
#total_changes ⇒ Object
508 509 510 511 512 |
# File 'lib/libsql.rb', line 508 def total_changes raise ClosedException if closed? @inner.info[:total_changes] end |
#transaction ⇒ Object
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'lib/libsql.rb', line 491 def transaction raise ClosedException if closed? 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 |