Method: SQLite3::Database#initialize
- Defined in:
- lib/sqlite3/database.rb
#initialize(file_name, options = {}) ⇒ Database
Create a new Database object that opens the given file. If utf16 is true, the filename is interpreted as a UTF-16 encoded string.
By default, the new database will return result rows as arrays (#results_as_hash) and has type translation disabled (#type_translation=).
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/sqlite3/database.rb', line 70 def initialize( file_name, ={} ) # :yields: db utf16 = .fetch(:utf16, false) load_driver( [:driver] ) @statement_factory = [:statement_factory] || Statement result, @handle = @driver.open( file_name, utf16 ) Error.check( result, self, "could not open database" ) @closed = false @results_as_hash = .fetch(:results_as_hash,false) @type_translation = .fetch(:type_translation,false) @translator = nil @transaction_active = false if block_given? begin yield self ensure self.close end end end |