Class ActiveRecord::ConnectionAdapters::SQLiteAdapter
In: vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
Parent: AbstractAdapter

The SQLite adapter works with both the 2.x and 3.x series of SQLite with the sqlite-ruby drivers (available both as gems and from rubyforge.org/projects/sqlite-ruby/).

Options:

  • :database — Path to the database file.

Methods

Public Instance methods

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 87
87:       def disconnect!
88:         super
89:         @connection.close rescue nil
90:       end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 251
251:       def empty_insert_statement(table_name)
252:         "INSERT INTO #{table_name} VALUES(NULL)"
253:       end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 213
213:       def rename_table(name, new_name)
214:         execute "ALTER TABLE #{name} RENAME TO #{new_name}"
215:       end

[Source]

    # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 83
83:       def requires_reloading?
84:         true
85:       end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 149
149:       def select_rows(sql, name = nil)
150:         execute(sql, name).map do |row|
151:           (0...(row.size / 2)).map { |i| row[i] }
152:         end
153:       end

Protected Instance methods

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 345
345:         def catch_schema_changes
346:           return yield
347:         rescue ActiveRecord::StatementInvalid => exception
348:           if exception.message =~ /database schema has changed/
349:             reconnect!
350:             retry
351:           else
352:             raise
353:           end
354:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 360
360:         def default_primary_key_type
361:           if supports_autoincrement?
362:             'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze
363:           else
364:             'INTEGER PRIMARY KEY NOT NULL'.freeze
365:           end
366:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 356
356:         def sqlite_version
357:           @sqlite_version ||= select_value('select sqlite_version(*)')
358:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 268
268:         def table_structure(table_name)
269:           returning structure = execute("PRAGMA table_info(#{table_name})") do
270:             raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
271:           end
272:         end

[Validate]