sqlitecommand-line-interfaceandroid-sqlitesqlitejdbc

How to enable SQLite3 cli to load an extension


I have downloaded the extension I want in sqlite3 which is spellfix and when I open sqlite3 to enable it the cli is not able to recognize the sqlite function

Not sure how to load the extension spellfix.dll pretty much I have the same error descriped here (I checked the answers too and not working)

I have tried the following

discordbot\database> sqlite3 database.db
SQLite version 3.42.0 2023-05-16 12:36:15
Enter ".help" for usage hints.
sqlite> .load ./spellfix
Error: unknown command or invalid arguments:  "load". Enter ".help" for help
sqlite> .dbconfig load_extension on
     load_extension on
sqlite> SELECT load_extension('./spellfix');
Parse error: no such function: load_extension
  SELECT load_extension('./spellfix');
         ^--- error here
sqlite> SELECT load_extension('spellfix');
Parse error: no such function: load_extension
  SELECT load_extension('spellfix');
         ^--- error here
sqlite>

Solution

  • First check your current directory in the sqlite shell (assuming that your are on Windows here given the .dll file).

    sqlite> .shell cd
    

    The output of this command will tell you where on your filesystem to place the extension. For example, you might be working in a specific project directory. Then, place your .dll file in that location. Then, within the sqlite shell you can load your extension.

    sqlite> .load spellfix.dll
    

    On my machine (a Linux machine), I see output like this.

    ~ $ sqlite3
    SQLite version 3.46.0 2024-05-23 13:25:27
    Enter ".help" for usage hints.
    Connected to a transient in-memory database.
    Use ".open FILENAME" to reopen on a persistent database.
    sqlite> .shell pwd
    /home/admin
    sqlite> .load myextension.so
    Error: myextension.so.so: cannot open shared object file: No such file or directory
    sqlite> 
    

    If you don't see similar output, try grabbing the sqlite-tools-win-x64-*.zip file from the SQLite Downloads page sqlite.org/download.html and using the sqlite3.exe found in there.