Xqlite.Pragma (Xqlite v0.7.0)

View Source

Deals with Sqlite pragmas.

This module deliberately omits the PRAGMAs that are deprecated, or are used with non-standard sqlite compile options, or are intended for testing sqlite.

Summary

Functions

Returns the names of all PRAGMAs supported by this library.

Fetches a PRAGMA's value, optionally specifying an extra argument

Returns column information for the given index.

Returns the list of indexes for the given table.

Returns extended column information for the given index, including key vs auxiliary columns.

Changes a PRAGMA's value.

A convenience wrapper to extract the :rows from a successful XqliteNIF.query/3 call.

Returns the names of all readable PRAGMAs that require one argument.

Returns the names of all readable PRAGMAs that don't require an argument.

Returns the names of all pragmas that return a boolean.

Returns the names of all pragmas that return an integer.

Returns the names of all pragmas that return a list.

Returns the names of all pragmas that return nothing.

Returns the names of all pragmas that return text.

Returns a map of all supported PRAGMAs keyed by name, with %PragmaSpec{} structs describing each PRAGMA's capabilities.

Returns column information for the given table.

Returns extended column information for the given table, including hidden and generated columns.

Returns a map of writable PRAGMAs to their allowed value specs.

Returns the names of all writable PRAGMAs.

Types

auto_vacuum_key()

@type auto_vacuum_key() :: 0 | 1 | 2

auto_vacuum_value()

@type auto_vacuum_value() :: :none | :full | :incremental

get_result()

@type get_result() ::
  {:ok, integer() | float() | boolean() | atom() | String.t() | list() | nil}
  | Xqlite.error()

list_result()

@type list_result() :: {:ok, list()} | Xqlite.error()

name()

@type name() :: String.t()

pragma_key()

@type pragma_key() :: String.t() | atom()

pragma_opts()

@type pragma_opts() :: keyword()

pragma_value()

@type pragma_value() :: String.t() | integer() | boolean() | atom()

secure_delete_key()

@type secure_delete_key() :: 0 | 1 | 2

secure_delete_value()

@type secure_delete_value() :: true | false | :fast

synchronous_key()

@type synchronous_key() :: 0 | 1 | 2 | 3

synchronous_value()

@type synchronous_value() :: :off | :normal | :full | :extra

temp_store_key()

@type temp_store_key() :: 0 | 1 | 2

temp_store_value()

@type temp_store_value() :: :default | :file | :memory

Functions

all()

@spec all() :: [atom()]

Returns the names of all PRAGMAs supported by this library.

get(db, key, arg_or_opts \\ [], opts \\ [])

Fetches a PRAGMA's value, optionally specifying an extra argument:

  • get(db, :auto_vacuum) is a PRAGMA that does not require an extra argument.
  • get(db, :table_info, :users) is a PRAGMA that does require an extra argument.

The last argument is a list of options:

  • :db_name - must be a string. The values "main" and "temp" are treated specially, as in instruct sqlite to use the main (originally opened) database or a temporary DB respectively. Any other value refers to a name of an ATTACH-ed database. This function will fail if there is no ATTACH-ed database with the specified name.

index_info(db, name, opts \\ [])

@spec index_info(Xqlite.conn(), name(), pragma_opts()) :: list_result()

Returns column information for the given index.

index_list(db, name, opts \\ [])

@spec index_list(Xqlite.conn(), name(), pragma_opts()) :: list_result()

Returns the list of indexes for the given table.

index_xinfo(db, name, opts \\ [])

@spec index_xinfo(Xqlite.conn(), name(), pragma_opts()) :: list_result()

Returns extended column information for the given index, including key vs auxiliary columns.

put(db, key, val, opts \\ [])

@spec put(Xqlite.conn(), pragma_key(), pragma_value(), pragma_opts()) ::
  {:ok, term()} | Xqlite.error()

Changes a PRAGMA's value.

Options

  • :db_name (string) - Target a specific attached database schema. "main" and "temp" are built-in; other values refer to ATTACH-ed databases.

query_to_pragma_result(err)

@spec query_to_pragma_result({:ok, Xqlite.query_result()} | Xqlite.error()) ::
  list_result()

A convenience wrapper to extract the :rows from a successful XqliteNIF.query/3 call.

readable_with_one_arg()

@spec readable_with_one_arg() :: [atom()]

Returns the names of all readable PRAGMAs that require one argument.

readable_with_zero_args()

@spec readable_with_zero_args() :: [atom()]

Returns the names of all readable PRAGMAs that don't require an argument.

returning_boolean()

@spec returning_boolean() :: [atom()]

Returns the names of all pragmas that return a boolean.

returning_int()

@spec returning_int() :: [atom()]

Returns the names of all pragmas that return an integer.

returning_list()

@spec returning_list() :: [atom()]

Returns the names of all pragmas that return a list.

returning_nothing()

@spec returning_nothing() :: [atom()]

Returns the names of all pragmas that return nothing.

returning_text()

@spec returning_text() :: [atom()]

Returns the names of all pragmas that return text.

schema()

@spec schema() :: %{required(atom()) => Xqlite.PragmaSpec.t()}

Returns a map of all supported PRAGMAs keyed by name, with %PragmaSpec{} structs describing each PRAGMA's capabilities.

table_info(db, name, opts \\ [])

@spec table_info(Xqlite.conn(), name(), pragma_opts()) :: list_result()

Returns column information for the given table.

table_xinfo(db, name, opts \\ [])

@spec table_xinfo(Xqlite.conn(), name(), pragma_opts()) :: list_result()

Returns extended column information for the given table, including hidden and generated columns.

valid_write_arg_values()

@spec valid_write_arg_values() :: %{required(atom()) => Range.t() | list()}

Returns a map of writable PRAGMAs to their allowed value specs.

writable()

@spec writable() :: [atom()]

Returns the names of all writable PRAGMAs.