The SQLite3
adapter works 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_check_constraints?,
- supports_common_table_expressions?,
- supports_concurrent_connections?,
- 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_transaction_isolation?,
- 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" }, } |
TYPE_MAP | = | Type::TypeMap.new.tap { |m| initialize_type_map(m) } |
Class Public methods
database_exists?(config) Link
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 92 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
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, e.g. ‘UTF-8’
foreign_keys(table_name) Link
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 305 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')
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 237 def rename_table(table_name, new_name) schema_cache.clear_data_source_cache!(table_name.to_s) schema_cache.clear_data_source_cache!(new_name.to_s) exec_query "ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}" rename_table_indexes(table_name, new_name) end