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
Classes and Modules
Class ActiveRecord::ConnectionAdapters::SQLiteAdapter::Version
Public Class methods
new(connection, logger, config)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 98
 98:       def initialize(connection, logger, config)
 99:         super(connection, logger)
100:         @config = config
101:       end
Public Instance methods
change_column_null(table_name, column_name, null, default = nil)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 288
288:       def change_column_null(table_name, column_name, null, default = nil)
289:         unless null || default.nil?
290:           execute("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL")
291:         end
292:         alter_table(table_name) do |definition|
293:           definition[column_name].null = null
294:         end
295:       end
disconnect!()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 127
127:       def disconnect!
128:         super
129:         @connection.close rescue nil
130:       end
empty_insert_statement(table_name)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 316
316:       def empty_insert_statement(table_name)
317:         "INSERT INTO #{table_name} VALUES(NULL)"
318:       end
rename_table(name, new_name)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 252
252:       def rename_table(name, new_name)
253:         execute "ALTER TABLE #{name} RENAME TO #{new_name}"
254:       end
requires_reloading?()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 119
119:       def requires_reloading?
120:         true
121:       end
select_rows(sql, name = nil)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 189
189:       def select_rows(sql, name = nil)
190:         execute(sql, name).map do |row|
191:           (0...(row.size / 2)).map { |i| row[i] }
192:         end
193:       end
supports_add_column?()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 123
123:       def supports_add_column?
124:         sqlite_version >= '3.1.6'
125:       end
supports_ddl_transactions?()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 107
107:       def supports_ddl_transactions?
108:         sqlite_version >= '2.0.0'
109:       end
valid_alter_table_options( type, options)

See: www.sqlite.org/lang_altertable.html SQLite has an additional restriction on the ALTER TABLE statement

     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 258
258:       def valid_alter_table_options( type, options)
259:         type.to_sym != :primary_key
260:       end
Protected Instance methods
catch_schema_changes() {|| ...}
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 418
418:         def catch_schema_changes
419:           return yield
420:         rescue ActiveRecord::StatementInvalid => exception
421:           if exception.message =~ /database schema has changed/
422:             reconnect!
423:             retry
424:           else
425:             raise
426:           end
427:         end
default_primary_key_type()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 433
433:         def default_primary_key_type
434:           if supports_autoincrement?
435:             'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze
436:           else
437:             'INTEGER PRIMARY KEY NOT NULL'.freeze
438:           end
439:         end
sqlite_version()
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 429
429:         def sqlite_version
430:           @sqlite_version ||= SQLiteAdapter::Version.new(select_value('select sqlite_version(*)'))
431:         end
table_structure(table_name)
     # File activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 333
333:         def table_structure(table_name)
334:           execute("PRAGMA table_info(#{quote_table_name(table_name)})").tap do |structure|
335:             raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
336:           end
337:         end