This script produces a sqlite3 binary with the necessary extensions to recover a Calibre metadata.db database. This seems to have worked for me, but I am not affiliated with the Calibre project, and it's also very possible that this will break your Calibre database in some subtle way. YMMV
First run calibre-sqlite.sh
to produce a sqlite3 binary:
chmod +x calibre-sqlite.sh
./calibre-sqlite.sh