Class: Makanai::Dbms::Sqlite
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #execute_sql(sql) ⇒ Object
-
#initialize(config) ⇒ Sqlite
constructor
A new instance of Sqlite.
Constructor Details
#initialize(config) ⇒ Sqlite
Returns a new instance of Sqlite.
8 9 10 11 12 |
# File 'lib/makanai/dbms/sqlite.rb', line 8 def initialize(config) super() @db = SQLite3::Database.new(config[:path]) db.tap { |db| db.results_as_hash = true } end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
14 15 16 |
# File 'lib/makanai/dbms/sqlite.rb', line 14 def db @db end |
Instance Method Details
#execute_sql(sql) ⇒ Object
16 17 18 |
# File 'lib/makanai/dbms/sqlite.rb', line 16 def execute_sql(sql) db.execute(sql).tap { close_db } end |