View Source Adbc.Database (adbc v0.6.5)

Documentation for Adbc.Database.

Databases are modelled as processes. They required a driver to be started.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get a binary (bytes) type option of the database.

Get a float type option of the database.

Get an integer type option of the database.

Get a string type option of the database.

Set option for the database.

Starts a database process.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_binary_option(db, key)

View Source
@spec get_binary_option(pid(), atom() | String.t()) ::
  {:ok, binary()} | {:error, String.t()}

Get a binary (bytes) type option of the database.

Link to this function

get_float_option(db, key)

View Source
@spec get_float_option(pid(), atom() | String.t()) ::
  {:ok, float()} | {:error, String.t()}

Get a float type option of the database.

Link to this function

get_integer_option(db, key)

View Source
@spec get_integer_option(pid(), atom() | String.t()) ::
  {:ok, integer()} | {:error, String.t()}

Get an integer type option of the database.

Link to this function

get_string_option(db, key)

View Source
@spec get_string_option(pid(), atom() | String.t()) ::
  {:ok, String.t()} | {:error, String.t()}

Get a string type option of the database.

Link to this function

set_option(db, key, value)

View Source
@spec set_option(
  pid(),
  atom() | String.t(),
  atom() | {:binary, iodata()} | String.t() | number()
) :: :ok | {:error, String.t()}

Set option for the database.

  • If value is an atom or a string, then corresponding string option will be set.
  • If value is a {:binary, iodata()}-tuple, then corresponding binary option will be set.
  • If value is an integer, then corresponding integer option will be set.
  • If value is a float, then corresponding float option will be set.

Starts a database process.

Options

  • :driver (required) - the driver to use for this database. It must be an atom (see Adbc module documentation for all built-in drivers) or a string representing the path to a driver

  • :process_options - the options to be given to the underlying process. See GenServer.start_link/3 for all options

All other options are given as database options to the underlying driver.

Examples

Adbc.Database.start_link(
  driver: :sqlite,
  process_options: [name: MyApp.DB]
)

In your supervision tree it would be started like this:

children = [
  {Adbc.Database,
   driver: :sqlite,
   process_options: [name: MyApp.DB]},
]