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 scanningdelta- Delta Lake table scanningduckdb- DuckDB database integrationfts- Full-text search using BM25 algorithmhttpfs- HTTP(S) file operations and remote database attachmenticeberg- Iceberg table scanningjson- JSON data scanning and manipulationllm- Text embeddings generation via external APIsneo4j- Neo4j data migrationpostgres- PostgreSQL database integrationsqlite- SQLite database integrationunity- Unity Catalog table scanningvector- 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
Functions
@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"}
@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
@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"}
@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
@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
@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
@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
@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.
@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", ...}
@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", ...}
@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"]
@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"]
@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"}
@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
@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
@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
@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
@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
@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