Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems trying to use loadExtension and 'better-sqlite3' #83

Closed
stuartambient opened this issue Jun 12, 2023 · 4 comments
Closed

Problems trying to use loadExtension and 'better-sqlite3' #83

stuartambient opened this issue Jun 12, 2023 · 4 comments

Comments

@stuartambient
Copy link

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
Copy link

asg017 commented Jun 12, 2023

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

@stuartambient
Copy link
Author

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

@asg017
Copy link

asg017 commented Jun 12, 2023

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

@stuartambient
Copy link
Author

Thank you, that worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants