Skip to content

Commit d2bbc9a

Browse files
committed
v3.8.5
1 parent 5223eab commit d2bbc9a

File tree

14 files changed

+551
-371
lines changed

14 files changed

+551
-371
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- uses: actions/setup-node@v4
1212
with:
13-
node-version: '22.x'
13+
node-version: '24'
1414
registry-url: 'https://registry.npmjs.org'
1515
- run: npm install -g npm
1616
- run: npm ci
17-
- run: npm publish --provenance
18-
env:
19-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17+
- run: npm publish

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634634
sqlite-electron module for electron and nodejs
635-
Copyright (C) 2020-2025 Motagamwala Taha Arif Ali
635+
Copyright (C) 2020-2026 Motagamwala Taha Arif Ali
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
sqlite-electron Copyright (C) 2020-2025 Motagamwala Taha Arif Ali
655+
sqlite-electron Copyright (C) 2020-2026 Motagamwala Taha Arif Ali
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Sqlite Electron
22

3-
Sqlite Electron is a module for electron to use sqlite3 database without rebuilding it supports Windows (x64, x32) and Linux (x64, arm64). It supports ESM and CJS.
3+
Sqlite Electron is a module for electron to use sqlite3 database without rebuilding it supports Windows (x64, x32, arm64), Linux (x64, arm64), and MacOS (x64, arm64). ESM and CJS modules are supported.
44

55
Changes:
66

7-
*iterdump function to generate an iterable of SQL commands that can recreate the entire database schema and data*
7+
*MacOS is now Supported :tada:*
88

9-
*Added autocommit option in setdbPath to make the commit and rollback either auto or manual*
9+
*Can use objects as well as arrays when binding the values with the sql statement using named parameters*
10+
11+
*Use env var **SQEL_PLATFORM_ARCH_IDENTIFIER** to download any platform binaries on any other platform eg. create electron app for macOS on the windows the sqlite-electron will install the macOS related binary when used the env var. For valid options see below*
1012

1113
## Installation
1214

@@ -24,15 +26,23 @@ Use the package manager [yarn](https://yarnpkg.com/package/sqlite-electron) to i
2426
yarn add sqlite-electron
2527
```
2628

27-
## Notes
29+
**SQEL_PLATFORM_ARCH_IDENTIFIER**
30+
31+
The valid options for this env variable are as follows
32+
33+
*1. win32-x64, win32-ia32, win32-arm64*
34+
35+
*2. linux-x64, linux-arm64*
2836

29-
*1. Due to package building issues the sqlite3 prebuilt for x32 windows system is currently unavailable for version 3.3.5 it will be available as soon as issues are resolved.*
37+
*3. darwin-x64, darwin-arm64*
3038

31-
*2. The package installs the prebuilt binaries of the sqlite on your system (if your system is supported) if you want any other platform binaries for a specific version go to https://github.com/tmotagam/sqlite-electron/releases.*
39+
## Notes
40+
41+
*1. The package installs the prebuilt binaries of the sqlite on your system (if your system is supported)*
3242

33-
*3. The example written for this library disregards the required security for the electron apps so do not use it as starting point in your applications.*
43+
*2. The example written for this library disregards the required security for the electron apps so do not use it as starting point in your applications.*
3444

35-
*4. Never give values in the query string use values array for giving the values for the query not taking this precaution will result in SQL injection attacks !.*
45+
*3. Never give values in the query string use values array for giving the values for the query not taking this precaution will result in SQL injection attacks !.*
3646

3747
Good parctice example
3848

@@ -58,12 +68,12 @@ executeQuery(
5868
| Api | Description |
5969
| ------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------: |
6070
| setdbPath(path='', isuri=false, autocommit=true) | It opens or creates the database for operation supports the InMemory databases and also SQLite URI format also the database path can be relative or absolute. Added autocommit to make the sql transaction either commit or rollback automatically or manually |
61-
| executeQuery(query = '', values = []) | It Executes single query with values they must be array |
71+
| executeQuery(query = '', values = []) | It Executes single query with values they can be array or object |
6272
| executeMany(query = '', values = []) | It executes single query with multiple values |
6373
| executeScript(scriptname = '') | It execute the SQL script scriptName must be name of the script or the script itself |
64-
| fetchAll(query = '', values = []) | It fetches all the values that matches the query. The values can also be given for the query using values array |
65-
| fetchOne(query = '', values = []) | It fetches only one value that matches the query. The values can also be given for the query using values array |
66-
| fetchMany(query = '', size = 5 values = []) | It fetches as many values as defined in size parameter that matches the query. The values can also be given for the query using values array
74+
| fetchAll(query = '', values = []) | It fetches all the values that matches the query. The values can also be given for the query using values array or object |
75+
| fetchOne(query = '', values = []) | It fetches only one value that matches the query. The values can also be given for the query using values array or object |
76+
| fetchMany(query = '', size = 5 values = []) | It fetches as many values as defined in size parameter that matches the query. The values can also be given for the query using values arrays or array of object
6777
| load_extension(path = '') | It loads SQLite extension from the given path for the connected database. |
6878
| backup(target='', pages=-1, name='main', sleep=0.250) | It backs up the database to the target database. The pages can be used if the database is very big. The name is used for the database to backup. Sleep is used to pause the operation for the specified seconds between backup of the specified number of pages. |
6979
| iterdump(file='', filter=null) | It generates an iterable of SQL commands that can recreate the entire database schema and data. The file parameter is used to save all the generated SQL commands. The filter is used to filter the databases to be generated as SQL commands the default is null which means the entire database is to be generated. |
@@ -176,14 +186,14 @@ app.on("window-all-closed", () => {
176186
// Your Code
177187
});
178188

179-
ipcMain.handle("Databasewithautocommit", async (event, dbPath, isuri, autocommit) => {
180-
return await sqlite.setdbPath(dbPath, isuri, autocommit);
189+
ipcMain.handle("Databasewithautocommit", async (event, dbPath, isuri) => {
190+
return await sqlite.setdbPath(dbPath, isuri, false);
181191
});
182192
```
183193

184194
### executeQuery
185195

186-
This is the function for executing any single query eg: 'INSERT INTO tutorial (x) VALUES (?)' you can give values through the values array.
196+
This is the function for executing any single query eg: 'INSERT INTO tutorial (x) VALUES (?)' you can give values using array or object.
187197

188198
```javascript
189199
const { app, BrowserWindow, ipcMain } = require("electron");
@@ -204,14 +214,18 @@ ipcMain.handle("databasePath", async (event, dbPath) => {
204214
return await sqlite.setdbPath(dbPath);
205215
});
206216

207-
ipcMain.handle("executeQuery", async (event, query, values) => {
208-
return await sqlite.executeQuery(query, values);
217+
ipcMain.handle("executeQueryArray", async (event, query, values) => {
218+
return await sqlite.executeQuery(query, []);
219+
});
220+
221+
ipcMain.handle("executeQueryObject", async (event, query, values) => {
222+
return await sqlite.executeQuery(query, {});
209223
});
210224
```
211225

212226
### fetchAll
213227

214-
This is the function for fetching all the rows that can be retrived using the given query eg: 'SELECT \* from tutorial' you can give values through the values array they will return the data in the Object format like this [{name: 'b', ...}, {name: 'a', ...}, {name: 'c', ...}].
228+
This is the function for fetching all the rows that can be retrived using the given query eg: 'SELECT \* from tutorial' you can give values array or object it will return the data in the Object format like this [{name: 'b', ...}, {name: 'a', ...}, {name: 'c', ...}].
215229

216230
```javascript
217231
const { app, BrowserWindow, ipcMain } = require("electron");
@@ -239,7 +253,7 @@ ipcMain.handle("fetchAll", async (event, query, values) => {
239253

240254
### fetchOne
241255

242-
This is the function for fetching only one row that can be retrived using the given query eg: 'SELECT \* from tutorial WHERE ID=?' you can give values through the values array they will return the data in the Object format like this {name: 'a', ...}.
256+
This is the function for fetching only one row that can be retrived using the given query eg: 'SELECT \* from tutorial WHERE ID=?' you can give values array or object it will return the data in the Object format like this {name: 'a', ...}.
243257

244258
```javascript
245259
const { app, BrowserWindow, ipcMain } = require("electron");
@@ -267,7 +281,7 @@ ipcMain.handle("fetchOne", async (event, query, values) => {
267281

268282
### fetchMany
269283

270-
This is the function for fetching as many rows as the size parameter allows that can be retrived using the given query eg: 'SELECT \* from tutorial WHERE name=?' you can give values through the values array they will return the data in the Object format like this [{name: 'a', ...}, {name: 'a', ...}, {name: 'a', ...}].
284+
This is the function for fetching as many rows as the size parameter allows that can be retrived using the given query eg: 'SELECT \* from tutorial WHERE name=?' you can give values through the values arrays or array of object it will return the data in the Object format like this [{name: 'a', ...}, {name: 'a', ...}, {name: 'a', ...}].
271285

272286
```javascript
273287
const { app, BrowserWindow, ipcMain } = require("electron");
@@ -297,7 +311,9 @@ ipcMain.handle("fetchMany", async (event, query, size, values) => {
297311

298312
This is the function for executing query with multiple values.
299313

300-
eg: ("INSERT INTO sqlite_main (NAME,AGE,ADDRESS,SALARY) VALUES (?, ?, ?, ?)", [["Pa", 32, "California", 20000.00], ["Pau", 32, "California", 20000.00], ["P", 32, "California", 20000.00], ["l", 32, "California", 20000.00]]) .
314+
eg: ("INSERT INTO sqlite_main (NAME,AGE,ADDRESS,SALARY) VALUES (?, ?, ?, ?)", [ ["Pa", 32, "California", 20000.00], ["Pau", 32, "California", 20000.00], ["P", 32, "California", 20000.00], ["l", 32, "California", 20000.00] ]) .
315+
316+
eg: (query='INSERT INTO sqlite_master (name, email, joining_date, salary) values(:name, :email, :joining_date, :salary)', values=[{'name':'John Doe','email':'example@sqlite-electron.com','joining_date':'1250-12-19','salary':8000000}]) .
301317

302318
```javascript
303319
const { app, BrowserWindow, ipcMain } = require("electron");
@@ -449,7 +465,7 @@ ipcMain.handle("iterdump", async (event, file, filter) => {
449465

450466
## Example
451467

452-
**[See sqlite-electron in action using electron 37.2.3](https://github.com/tmotagam/sqlite-electron/tree/master/example)**
468+
**[See sqlite-electron in action using electron 40.0.0](https://github.com/tmotagam/sqlite-electron/tree/master/example)**
453469

454470
## Contributing
455471

0 commit comments

Comments
 (0)