View Source LadybugEx.Extensions (LadybugEx v0.2.0)

Generic interface for managing LadybugDB extensions.

LadybugDB provides official extensions that add specialized functionality to the database. Extensions must be installed (one-time download) and then loaded (per-session activation) before use.

Available Extensions

  • algo - Graph algorithms (PageRank, SCC, WCC, Louvain, K-Core)
  • azure - Azure Blob Storage and ADLS scanning
  • delta - Delta Lake table scanning
  • duckdb - DuckDB database integration
  • fts - Full-text search using BM25 algorithm
  • httpfs - HTTP(S) file operations and remote database attachment
  • iceberg - Iceberg table scanning
  • json - JSON data scanning and manipulation
  • llm - Text embeddings generation via external APIs
  • neo4j - Neo4j data migration
  • postgres - PostgreSQL database integration
  • sqlite - SQLite database integration
  • unity - Unity Catalog table scanning
  • vector - Vector similarity search with HNSW indexing

Usage

# Install and load an extension
{:ok, _} = Extensions.install_and_load(conn, "vector")

# Check if extension is loaded
true = Extensions.loaded?(conn, "vector")

# List all available extensions
{:ok, extensions} = Extensions.list_available(conn)

# List loaded extensions
{:ok, loaded} = Extensions.list_loaded(conn)

Session Scope

Extensions are scoped to the connection session. You must load extensions for each new connection where you want to use them.

Summary

Functions

Ensure an extension is loaded, loading it if necessary.

Ensure an extension is loaded, loading it if necessary.

Install an extension from the official extension server.

Install an extension from the official extension server.

Install and load an extension in one operation.

Install and load an extension in one operation.

Install an extension from a custom server or file path.

Install an extension from a custom server or file path.

List all available official extensions.

List all available official extensions.

List all loaded extensions in the current connection.

List all loaded extensions in the current connection.

Load an extension for the current connection session.

Load an extension for the current connection session.

Check if an extension is loaded in the current connection.

Uninstall an extension, removing it from the file system.

Uninstall an extension, removing it from the file system.

Update an extension by re-downloading it from the extension server.

Update an extension by re-downloading it from the extension server.

Types

error()

@type error() :: {:error, String.t()}

extension_info()

@type extension_info() :: %{required(String.t()) => any()}

extension_name()

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

Functions

ensure_loaded(conn, extension_name)

@spec ensure_loaded(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Ensure an extension is loaded, loading it if necessary.

This is useful in modules that depend on specific extensions. If the extension is already loaded, this is a no-op. If not, it attempts to load the extension.

Examples

iex> Extensions.ensure_loaded(conn, "vector")
:ok

iex> Extensions.ensure_loaded(conn, "not_installed")
{:error, "Extension 'not_installed' is not installed"}

ensure_loaded!(conn, extension_name)

@spec ensure_loaded!(LadybugEx.Connection.t(), extension_name()) :: :ok

Ensure an extension is loaded, loading it if necessary.

Raises an error if the extension cannot be loaded.

Examples

iex> Extensions.ensure_loaded!(conn, "vector")
:ok

install(conn, extension_name)

@spec install(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Install an extension from the official extension server.

This downloads the extension to the local file system. Installation is only needed once per extension, not per session.

Examples

iex> Extensions.install(conn, "vector")
:ok

iex> Extensions.install(conn, "nonexistent")
{:error, "Extension 'nonexistent' not found"}

install!(conn, extension_name)

@spec install!(LadybugEx.Connection.t(), extension_name()) :: :ok

Install an extension from the official extension server.

Raises an error if the installation fails.

Examples

iex> Extensions.install!(conn, "vector")
:ok

install_and_load(conn, extension_name)

@spec install_and_load(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Install and load an extension in one operation.

Convenience function that installs the extension if needed, then loads it for the current connection.

Examples

iex> Extensions.install_and_load(conn, "vector")
:ok

install_and_load!(conn, extension_name)

@spec install_and_load!(LadybugEx.Connection.t(), extension_name()) :: :ok

Install and load an extension in one operation.

Raises an error if either operation fails.

Examples

iex> Extensions.install_and_load!(conn, "vector")
:ok

install_from(conn, extension_name, source)

@spec install_from(LadybugEx.Connection.t(), extension_name(), String.t()) ::
  :ok | error()

Install an extension from a custom server or file path.

Examples

iex> Extensions.install_from(conn, "myext", "https://myserver.com/extensions")
:ok

iex> Extensions.install_from(conn, "myext", "/path/to/myext.lbug_extension")
:ok

install_from!(conn, extension_name, source)

@spec install_from!(LadybugEx.Connection.t(), extension_name(), String.t()) :: :ok

Install an extension from a custom server or file path.

Raises an error if the installation fails.

list_available(conn)

@spec list_available(LadybugEx.Connection.t()) :: {:ok, [extension_info()]} | error()

List all available official extensions.

Returns a list of extension information including name, description, and version.

Examples

iex> {:ok, extensions} = Extensions.list_available(conn)
iex> Enum.find(extensions, &(&1["name"] == "vector"))
%{"name" => "vector", "description" => "Vector similarity search", ...}

list_available!(conn)

@spec list_available!(LadybugEx.Connection.t()) :: [extension_info()]

List all available official extensions.

Raises an error if the query fails.

Examples

iex> extensions = Extensions.list_available!(conn)
iex> Enum.find(extensions, &(&1["name"] == "vector"))
%{"name" => "vector", "description" => "Vector similarity search", ...}

list_loaded(conn)

@spec list_loaded(LadybugEx.Connection.t()) :: {:ok, [extension_info()]} | error()

List all loaded extensions in the current connection.

Examples

iex> {:ok, loaded} = Extensions.list_loaded(conn)
iex> Enum.map(loaded, &(&1["name"]))
["vector", "fts"]

list_loaded!(conn)

@spec list_loaded!(LadybugEx.Connection.t()) :: [extension_info()]

List all loaded extensions in the current connection.

Raises an error if the query fails.

Examples

iex> loaded = Extensions.list_loaded!(conn)
iex> Enum.map(loaded, &(&1["name"]))
["vector", "fts"]

load(conn, extension_name)

@spec load(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Load an extension for the current connection session.

Extensions must be loaded in every new connection where you want to use them. The extension must be installed first using install/2.

Examples

iex> Extensions.load(conn, "vector")
:ok

iex> Extensions.load(conn, "not_installed")
{:error, "Extension 'not_installed' is not installed"}

load!(conn, extension_name)

@spec load!(LadybugEx.Connection.t(), extension_name()) :: :ok

Load an extension for the current connection session.

Raises an error if the loading fails.

Examples

iex> Extensions.load!(conn, "vector")
:ok

loaded?(conn, extension_name)

@spec loaded?(LadybugEx.Connection.t(), extension_name()) :: boolean()

Check if an extension is loaded in the current connection.

Examples

iex> Extensions.loaded?(conn, "vector")
true

iex> Extensions.loaded?(conn, "not_loaded")
false

uninstall(conn, extension_name)

@spec uninstall(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Uninstall an extension, removing it from the file system.

Examples

iex> Extensions.uninstall(conn, "vector")
:ok

uninstall!(conn, extension_name)

@spec uninstall!(LadybugEx.Connection.t(), extension_name()) :: :ok

Uninstall an extension, removing it from the file system.

Raises an error if the uninstall fails.

Examples

iex> Extensions.uninstall!(conn, "vector")
:ok

update(conn, extension_name)

@spec update(LadybugEx.Connection.t(), extension_name()) :: :ok | error()

Update an extension by re-downloading it from the extension server.

Examples

iex> Extensions.update(conn, "vector")
:ok

update!(conn, extension_name)

@spec update!(LadybugEx.Connection.t(), extension_name()) :: :ok

Update an extension by re-downloading it from the extension server.

Raises an error if the update fails.

Examples

iex> Extensions.update!(conn, "vector")
:ok