New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sqlite-electron

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqlite-electron - npm Package Compare versions

Comparing version 2.0.0 to 2.0.5

scripts/postinstall.js

16

package.json
{
"name": "sqlite-electron",
"version": "2.0.0",
"version": "2.0.5",
"description": "A module for electron to use sqlite3 without rebuilding",
"main": "sqlite-electron.js",
"scripts": {},
"scripts": {
"postinstall": "node ./scripts/postinstall.js"
},
"author": "Motagamwala Taha Arif Ali",
"files": [
"sqlite-electron.js",
"sqlite-electron.d.ts",
"scripts"
],
"license": "GPL-3.0-or-later",
"keywords": [
"Sqlite3",
"sqlite-electron",
"sqlite3",
"sqlite"
"sqlite",
"electron",
"database"
],

@@ -15,0 +23,0 @@ "repository": {

# Sqlite Electron
Sqlite Electron is a module for electron and nodejs to use sqlite3 database without rebuilding as of now supports only Windows(win32).
Sqlite Electron is a module for electron to use sqlite3 database without rebuilding as of now supports Windows(win32) (x64, x32) and Linux (x64).

@@ -13,2 +13,7 @@ ## Installation

## Note
The package installs the prebuilt binaries of the sqlite on your system (if your system is supported) if you want any other platform binaries go to
https://github.com/tmotagam/sqlite-electron/tree/master/binaries
## Functions

@@ -49,3 +54,3 @@

Set this variable before using any of the 3 api.
Set this variable before using any of the api.

@@ -143,3 +148,3 @@ ```javascript

You have to give absolute path of the script.
You have to give absolute path of the script or give the script`s content directly as well.

@@ -175,2 +180,4 @@

return await sqlite.executeScript(scriptpath);
// or
return await sqlite.executeScript('CREATE TABLE IF NOT EXISTS sqlite_main (ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,NAME TEXT NOT NULL,AGE INT NOT NULL,ADDRESS CHAR(50) NOT NULL,SALARY REAL NOT NULL);');
})

@@ -181,6 +188,6 @@ ```

## Example
[See sqlite-electron in action using electron 15.3.0](https://github.com/tmotagam/sqlite-electron/tree/master/example)
[See sqlite-electron in action using electron 19.0.6](https://github.com/tmotagam/sqlite-electron/tree/master/example)
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Pull requests and issues are welcome. For major changes, please open an issue first to discuss what you would like to change.

@@ -187,0 +194,0 @@ [Github](https://github.com/tmotagam/sqlite-electron)

@@ -1,4 +0,4 @@

/*! *****************************************************************************
sqlite-electron module for electron and nodejs
Copyright (C) 2021 Motagamwala Taha Arif Ali
/*
sqlite-electron module
Copyright (C) 2022 Motagamwala Taha Arif Ali

@@ -17,132 +17,113 @@ This program is free software: you can redistribute it and/or modify

along with this program. If not, see <https://www.gnu.org/licenses/>.
***************************************************************************** */
*/
/**
* Module for using sqlite3 in electron without rebuilding works only on win32
*/
const { execFile } = require('child_process');
const path = require('path');
"use strict";
/**
* This is a internal function for detecting electron to get correct path
*/
// @ts-check
/** @type { import('./sqlite-electron.d.ts') } */
const electronNodeDetection = () => {
exports.__esModule = true;
var child_process_1 = require("child_process");
var path_1 = require("path");
var electronNodeDetection = function () {
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
if (process.defaultApp) {
return path.join(path.dirname(require.main.filename), module.exports.dbPath);
} else {
return path.join(path.dirname(process.execPath), module.exports.dbPath);
return (0, path_1.join)((0, path_1.dirname)(require.main.filename), module.exports.dbPath);
}
} else {
return path.join(path.dirname(require.main.filename), module.exports.dbPath);
else {
return (0, path_1.join)((0, path_1.dirname)(process.execPath), module.exports.dbPath);
}
}
}
/**
* Executes a single query takes 3 parameters
* @param Query The string for the SQL queries eg: SELECT * FROM tables.
* @param fetch(Optional) This is used to specify whether the user wants all the values from the table or single value or multiple values eg: "all", 1, 2, 3, .., .
* @param values(Optional) This is used for specifing values to be sent with the SQL queries eg: ["name", 20000, "example street", 1234567890].
* @returns Either true or an array when fetch is specified also returns error string when something goes wrong.
*/
const executeQuery = (Query = '', fetch = '', values = []) => {
return new Promise((resolve, reject) => {
else {
return (0, path_1.join)((0, path_1.dirname)(require.main.filename), module.exports.dbPath);
}
};
var executeQuery = function (Query, fetch, values) {
return new Promise(function (resolve, reject) {
try {
const fullpath = electronNodeDetection()
let sqlitePath = __dirname + '\\sqlite.exe';
sqlite = execFile(sqlitePath);
let string = '';
sqlite.stdin.write(JSON.stringify(['executeQuery', fullpath, Query, fetch, values]))
sqlite.stdin.end()
sqlite.stdout.on('data', (data) => {
string += data.toString()
})
sqlite.stdout.on('end', () => {
sqlite.kill()
resolve(JSON.parse(string))
})
} catch (error) {
reject(error)
var fullpath = electronNodeDetection();
var sqlitePath = '';
if (process.platform === 'win32') {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch, ".exe"));
}
else {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch));
}
var sqlite_1 = (0, child_process_1.execFile)(sqlitePath);
var string_1 = '';
sqlite_1.stdin.write(JSON.stringify(['executeQuery', fullpath, Query, fetch, values]));
sqlite_1.stdin.end();
sqlite_1.stdout.on('data', function (data) {
string_1 += data.toString();
});
sqlite_1.stdout.on('end', function () {
sqlite_1.kill();
resolve(JSON.parse(string_1));
});
}
catch (error) {
reject(error);
}
});
}
/**
* Executes a single query on multiple values
* @param Query The string for the SQL queries eg: SELECT * FROM tables.
* @param v This is used for specifing values to be sent with the SQL queries eg: [["name", 20000, "example street", 1234567890], ["name1", 20, "example street", 123]].
* @returns true or error string
*/
const executeMany = (Query = '', v = []) => {
return new Promise((resolve, reject) => {
};
var executeMany = function (Query, v) {
return new Promise(function (resolve, reject) {
try {
const fullpath = electronNodeDetection()
let sqlitePath = __dirname + '\\sqlite.exe';
sqlite = execFile(sqlitePath);
let string = '';
sqlite.stdout.on('data', (data) => {
string += data.toString()
})
sqlite.stdout.on('end', () => {
sqlite.kill()
resolve(JSON.parse(string))
})
sqlite.stdin.write(JSON.stringify(['executeMany', fullpath, Query, v]))
sqlite.stdin.end()
} catch (error) {
reject(error)
var fullpath = electronNodeDetection();
var sqlitePath = '';
if (process.platform === 'win32') {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch, ".exe"));
}
else {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch));
}
var sqlite_2 = (0, child_process_1.execFile)(sqlitePath);
var string_2 = '';
sqlite_2.stdout.on('data', function (data) {
string_2 += data.toString();
});
sqlite_2.stdout.on('end', function () {
sqlite_2.kill();
resolve(JSON.parse(string_2));
});
sqlite_2.stdin.write(JSON.stringify(['executeMany', fullpath, Query, v]));
sqlite_2.stdin.end();
}
catch (error) {
reject(error);
}
});
}
/**
*
* @param scriptName The path of the SQL script to execute eg: ./scripts/myScript.sql .
* @returns true or error string
*/
const executeScript = (scriptName = '') => {
return new Promise((resolve, reject) => {
};
var executeScript = function (scriptName) {
return new Promise(function (resolve, reject) {
try {
const fullpath = electronNodeDetection()
let sqlitePath = __dirname + '\\sqlite.exe';
sqlite = execFile(sqlitePath);
let string = '';
sqlite.stdout.on('data', (data) => {
string += data.toString()
})
sqlite.stdout.on('end', () => {
sqlite.kill()
resolve(JSON.parse(string))
})
sqlite.stdin.write(JSON.stringify(['executeScript', fullpath, scriptName]))
sqlite.stdin.end()
} catch (error) {
reject(error)
var fullpath = electronNodeDetection();
var sqlitePath = '';
if (process.platform === 'win32') {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch, ".exe"));
}
else {
sqlitePath = (0, path_1.join)(__dirname, "sqlite-".concat(process.platform, "-").concat(process.arch));
}
var sqlite_3 = (0, child_process_1.execFile)(sqlitePath);
var string_3 = '';
sqlite_3.stdout.on('data', function (data) {
string_3 += data.toString();
});
sqlite_3.stdout.on('end', function () {
sqlite_3.kill();
resolve(JSON.parse(string_3));
});
sqlite_3.stdin.write(JSON.stringify(['executeScript', fullpath, scriptName]));
sqlite_3.stdin.end();
}
catch (error) {
reject(error);
}
});
}
module.exports.dbPath = ''
module.exports.executeQuery = executeQuery
module.exports.executeMany = executeMany
module.exports.executeScript = executeScript
};
module.exports.dbPath = '';
module.exports.executeQuery = executeQuery;
module.exports.executeMany = executeMany;
module.exports.executeScript = executeScript;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc