The SQLite3
adapter works SQLite 3.6.16 or newer with the sqlite3-ruby drivers (available as gem from rubygems.org/gems/sqlite3).
Options:
-
:database
- Path to the database file.
Methods
- A
- D
- E
- F
- N
- R
- S
-
- supports_common_table_expressions?,
- supports_datetime_with_precision?,
- supports_ddl_transactions?,
- supports_explain?,
- supports_expression_index?,
- supports_foreign_keys?,
- supports_index_sort_order?,
- supports_insert_conflict_target?,
- supports_insert_on_conflict?,
- supports_insert_on_duplicate_skip?,
- supports_insert_on_duplicate_update?,
- supports_json?,
- supports_lazy_transactions?,
- supports_partial_index?,
- supports_savepoints?,
- supports_views?
Included Modules
Constants
ADAPTER_NAME | = | "SQLite" |
COLLATE_REGEX | = | /.*\"(\w+)\".*collate\s+\"(\w+)\".*/i.freeze |
NATIVE_DATABASE_TYPES | = | { primary_key: "integer PRIMARY KEY AUTOINCREMENT NOT NULL", string: { name: "varchar" }, text: { name: "text" }, integer: { name: "integer" }, float: { name: "float" }, decimal: { name: "decimal" }, datetime: { name: "datetime" }, time: { name: "time" }, date: { name: "date" }, binary: { name: "blob" }, boolean: { name: "boolean" }, json: { name: "json" }, } |
Class Public methods
database_exists?(config)
Link
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 101 def self.database_exists?(config) config = config.symbolize_keys if config[:database] == ":memory:" true else database_file = defined?(Rails.root) ? File.expand_path(config[:database], Rails.root) : config[:database] File.exist?(database_file) end end
new(connection, logger, connection_options, config)
Link
Instance Public methods
active?()
Link
allowed_index_name_length()
Link
Returns 62. SQLite supports index names up to 64 characters. The rest is used by Rails internally to perform temporary rename operations
disconnect!()
Link
Disconnects from the database if already connected. Otherwise, this method does nothing.
encoding()
Link
Returns the current database encoding format as a string, eg: 'UTF-8'
explain(arel, binds = [])
Link
foreign_keys(table_name)
Link
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 309 def foreign_keys(table_name) fk_info = exec_query("PRAGMA foreign_key_list(#{quote(table_name)})", "SCHEMA") fk_info.map do |row| options = { column: row["from"], primary_key: row["to"], on_delete: extract_foreign_key_action(row["on_delete"]), on_update: extract_foreign_key_action(row["on_update"]) } ForeignKeyDefinition.new(table_name, row["table"], options) end end
reconnect!()
Link
rename_table(table_name, new_name)
Link
Renames a table.
Example:
rename_table('octopuses', 'octopi')
requires_reloading?()
Link
supports_common_table_expressions?()
Link
supports_datetime_with_precision?()
Link
supports_ddl_transactions?()
Link
supports_explain?()
Link
supports_expression_index?()
Link
supports_foreign_keys?()
Link
supports_index_sort_order?()
Link
supports_insert_on_conflict?()
Link
supports_json?()
Link
supports_lazy_transactions?()
Link
supports_partial_index?()
Link
supports_savepoints?()
Link