Closed minevbg closed 7 months ago
Hello @minevbg, Please use the API like this for create the .db file, it will create the file automatically if it doesn't exists or open the already existing file.
(async () => {
try {
await sqlite.setdbPath('demo.db');
console.log('DB file created!');
}
catch(err) {
console.log(err);
}
})()
In your URI code use it like this and also read this link SQLITE URI.
sqlite.setdbPath("file:tutorial.db?mode:rwc", isuri=true)
regards.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm having this same problem. This is from my main.js
file:
app.whenReady().then(() => {
ipcMain.handle("databasePath", async (event, dbPath) => {
return (async () => {
try {
await sqlite.setdbPath(dbPath);
console.log("DB file created!");
} catch (err) {
console.log(err);
}
})();
});
createWindow();
});
I've checked that the dbPath value is correctly passed in from the render process.
When I inspect require.main
, I do see that it is undefined, which is the technical cause of the error (https://github.com/tmotagam/sqlite-electron/blob/master/sqlite-electron.ts#L26). I don't understand why this would be undefined, since this should be running in the main process.
I'm running on Windows 11 with electron v. 29.1.5
.
Do you have any suggestions?
I cannot create a database with sqlite.setdbPath.
Obviously, nothing else works after that.
Here is the error from console:
Same error if I try to do it with URI -
sqlite.setdbPath("file:tutorial.db?mode:rw", isuri=true)
It only works fine when I try to make it in memory with
sqlite.setdbPath(":memory:")
, no errors and sqlite executable is running.Any idea on how to troubleshoot this?
Electron version v28.2.3