SQLite Loading Extensions on MacOS

2024-07-09

MacOS comes with a default SQLite that doesn’t allow you to load extensions.

You can check by opening up sqlite with sqlite3 and running this:

select * from pragma_compile_options();

You should see OMIT_LOAD_EXTENSION , meaning that extensions can’t be loaded.

If you run which sqlite3 , you should see that it is in /usr/bin/sqlite3 .

The quickest way to get a SQLite that can load extensions is with Homebrew. Simply brew install homebrew .

You can confirm the path by checking the output under caveats when running brew info sqlite . It should be something like /opt/homebrew/opt/sqlite/bin/sqlite3 , but if you have an older OS or Homebrew, it might look something like /usr/local/opt/sqlite/bin/sqlite3 .

Now, if you want to use an extension like sqlean in your SQLite connection, you can simply run:

.load relative/path/to/file/sqlean