Class: Database
- Inherits:
-
Object
- Object
- Database
- Defined in:
- lib/fingerbank_client/database.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Database
constructor
A new instance of Database.
- #query(statement, *args) ⇒ Object
Constructor Details
#initialize ⇒ Database
Returns a new instance of Database.
11 12 13 |
# File 'lib/fingerbank_client/database.rb', line 11 def initialize self.db = SQLite3::Database.open "fingerbank.sqlite" end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
10 11 12 |
# File 'lib/fingerbank_client/database.rb', line 10 def db @db end |
Instance Method Details
#close ⇒ Object
26 27 28 |
# File 'lib/fingerbank_client/database.rb', line 26 def close self.db.close if db end |
#query(statement, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fingerbank_client/database.rb', line 15 def query(statement, *args) begin stm = db.prepare statement rs = stm.execute(*args) rescue SQLite3::Exception => e Fingerbank.logger.error "Fingerbank : Exception occurred while selecting in the database (#{e.})" self.close raise e end end |