Skip to content

Commit

Permalink
feat: add sqlite extension docs (#76)
Browse files Browse the repository at this point in the history
* feat: add sqlite extension docs

* fix: add platform specific info for sqlite extensions
  • Loading branch information
tconbeer authored Apr 25, 2024
1 parent 0c33c6a commit e2f7573
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/docs/sqlite/extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Loading Extensions
menuOrder: 32
---

## Warning: May not work on your platform!

Harlequin uses Python's distribution of SQLite, via its built-in `sqlite3` library. On some (most?) platforms, including MacOS and Ubuntu, this library [disables support for extensions](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.enable_load_extension). Windows is the notable exception where this should "just work."

To allow Harlequin to load SQLite extensions, you may have to rebuild your Python from source, passing specific [config](https://docs.python.org/3/using/configure.html#cmdoption-enable-loadable-sqlite-extensions) during the Python build process.

## Loading Extensions Using CLI Option

You can install and load [SQLite extensions](https://www.sqlite.org/loadext.html) when starting Harlequin, by invoking the `-e` or `--extension` option one or more times:

```bash
harlequin -e ./fts5 -e ./json1
```

The argument to the option should be a path to a SQLite extension executable. Loading specific entrypoints is not supported via the CLI option.

## Loading Extensions via Init Script or SQL API

You can use a `.load` command in an [initialization script](initialization) to load an extension (optionally specifying an entrypoint).

Or you can execute a `select load_extension(...)` statement in Harlequin's Query Editor.
2 changes: 1 addition & 1 deletion src/docs/sqlite/initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ Most SQLite CLI dot commands affect the behavior of the CLI, like the format of
Currently Harlequin rewrites the following dot commands to SQL and executes the SQL:

- `.open` is rewritten to an `attach ...` statement.
- `.load` is rewritten to a `select load_extension(...)` statement.
- `.load` is rewritten to a `select load_extension(...)` statement. Note: Loading extensions may not be possible with your Python's SQLite distribution. See [extensions](extensions) for more info.

To request additional dot command support in Harlequin, [open an issue](https://github.com/tconbeer/harlequin/issues/new/choose).

0 comments on commit e2f7573

Please sign in to comment.