Class: QueryKit::Adapters::SQLiteAdapter
- Defined in:
- lib/querykit/adapters/sqlite_adapter.rb
Instance Method Summary collapse
- #affected_rows ⇒ Object
- #begin_transaction ⇒ Object
- #close ⇒ Object
- #commit ⇒ Object
- #execute(sql, bindings = []) ⇒ Object
-
#initialize(database_path) ⇒ SQLiteAdapter
constructor
A new instance of SQLiteAdapter.
- #last_insert_id ⇒ Object
- #rollback ⇒ Object
Constructor Details
#initialize(database_path) ⇒ SQLiteAdapter
Returns a new instance of SQLiteAdapter.
8 9 10 11 12 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 8 def initialize(database_path) require 'sqlite3' @db = SQLite3::Database.new(database_path) @db.results_as_hash = true end |
Instance Method Details
#affected_rows ⇒ Object
22 23 24 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 22 def affected_rows @db.changes end |
#begin_transaction ⇒ Object
26 27 28 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 26 def begin_transaction @db.execute("BEGIN TRANSACTION") end |
#close ⇒ Object
38 39 40 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 38 def close @db.close end |
#commit ⇒ Object
30 31 32 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 30 def commit @db.execute("COMMIT") end |
#execute(sql, bindings = []) ⇒ Object
14 15 16 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 14 def execute(sql, bindings = []) @db.execute(sql, bindings) end |
#last_insert_id ⇒ Object
18 19 20 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 18 def last_insert_id @db.last_insert_row_id end |
#rollback ⇒ Object
34 35 36 |
# File 'lib/querykit/adapters/sqlite_adapter.rb', line 34 def rollback @db.execute("ROLLBACK") end |