Class: ItunesController::SQLite3DatabaseBackend
- Inherits:
-
DatabaseBackend
- Object
- DatabaseBackend
- ItunesController::SQLite3DatabaseBackend
- Defined in:
- lib/itunesController/database/sqlite3_backend.rb
Instance Method Summary collapse
- #close ⇒ Object
- #execute(sql) ⇒ Object
- #executeStatement(stmt, *args) ⇒ Object
-
#initialize(dbPath = nil) ⇒ SQLite3DatabaseBackend
constructor
A new instance of SQLite3DatabaseBackend.
- #prepare(sql) ⇒ Object
Constructor Details
#initialize(dbPath = nil) ⇒ SQLite3DatabaseBackend
Returns a new instance of SQLite3DatabaseBackend.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/itunesController/database/sqlite3_backend.rb', line 32 def initialize(dbPath=nil) if (dbPath==nil) dbPath=ItunesController::Platform::getUserHomeDir()+"/.itunesController/database.db" end if (!File.directory?(File.dirname(dbPath))) FileUtils::mkdir_p(File.dirname(dbPath)) end ItunesController::ItunesControllerLogging::info("Database path #{dbPath}") @db=SQLite3::Database.new( dbPath ) end |
Instance Method Details
#close ⇒ Object
63 64 65 |
# File 'lib/itunesController/database/sqlite3_backend.rb', line 63 def close() @db.close() end |
#execute(sql) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/itunesController/database/sqlite3_backend.rb', line 55 def execute(sql) begin return @db.execute(sql) rescue SQLite3::ConstraintException => e raise ItunesController::DatabaseConstraintException, e. end end |
#executeStatement(stmt, *args) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/itunesController/database/sqlite3_backend.rb', line 47 def executeStatement(stmt,*args) begin return stmt.execute(*args) rescue SQLite3::ConstraintException => e raise ItunesController::DatabaseConstraintException, e. end end |
#prepare(sql) ⇒ Object
43 44 45 |
# File 'lib/itunesController/database/sqlite3_backend.rb', line 43 def prepare(sql) return @db.prepare(sql) end |