Compile and load SQLite extensions

How to compile the UUID extension:

1
2
3
4
5
6
7
wget https://www.sqlite.org/src/tarball/sqlite.tar.gz
tar xzf sqlite.tar.gz
mkdir bld
cd bld
../sqlite/configure
make
gcc -g -I. -fPIC -dynamiclib ../sqlite/ext/misc/uuid.c -o uuid.dylib

Run the sqlite3 command-line program:

1
./sqlite3

Try to use the UUID extension without loading it:

1
2
3
4
sqlite> select uuid();
Parse error: no such function: uuid
  select uuid();
         ^--- error here

Load the UUID extension and use it:

1
2
3
sqlite> .load ./uuid
sqlite> select uuid();
945ef12d-f428-4b8a-831c-3a2fbe7c60b4

Tested on an Intel Macbook Pro.

Source: https://stackoverflow.com/a/61850934

Tags: TIL SQLite