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

External Aliases

remove_column -> remove_columns

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 258
258:       def empty_insert_statement(table_name)
259:         "INSERT INTO #{table_name} VALUES(NULL)"
260:       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 360
360:         def catch_schema_changes
361:           return yield
362:         rescue ActiveRecord::StatementInvalid => exception
363:           if exception.message =~ /database schema has changed/
364:             reconnect!
365:             retry
366:           else
367:             raise
368:           end
369:         end

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 375
375:         def default_primary_key_type
376:           if supports_autoincrement?
377:             'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze
378:           else
379:             'INTEGER PRIMARY KEY NOT NULL'.freeze
380:           end
381:         end

[Source]

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

[Source]

     # File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 275
275:         def table_structure(table_name)
276:           returning structure = execute("PRAGMA table_info(#{quote_table_name(table_name)})") do
277:             raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty?
278:           end
279:         end

[Validate]