nalgeon/sqlean

Problems trying to use loadExtension and 'better-sqlite3'

stuartambient opened this issue · 4 comments

Keep getting 'SqliteError: The specified module could not be found'
Using 'better-sql3' v 8.0.1

Trying to load it from the same directory where I declare the database:

import Database from 'better-sqlite3';
const db = new Database(`myapp/src/db/music.db`);
db.pragma('journal_mode = WAL');
db.pragma('synchronous = normal');
db.pragma('page_size = 32768');
db.pragma('mmap_size = 30000000000');
db.pragma('temp_store = memory');
db.loadExtension('./stats');

export default db;

afaik 'loadExtension' is still part of 'better-sqlite3'. I can get the extension recognized with SQLiteStudio no problem, just not here.

Help appreciated!

asg017 commented

Is the stats.dylib / stats.so / stats.dll file in the same directory where you are running your program?

yes, sorry, this is Windows, so stats.dll is in the same directory.

asg017 commented

Is the stats.dll file inside myapp/src/db directory next to your music.db file, by any chance? if so you can try:

db.loadExtension('myapp/src/db/stats');

The path to the extension you provide in loadExtension() is relative to the current working directory (import.meta.url), not to the connected database

Thank you, that worked!