Skip to content

Commit

Permalink
v3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tmotagam committed Dec 14, 2023
1 parent c3f28f7 commit 7d7f2d9
Show file tree
Hide file tree
Showing 15 changed files with 853 additions and 319 deletions.
134 changes: 134 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
tahaar5321@gmail.com .

All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing to sqlite-electron

Secweb welcomes contributors! This guide should help you submit issues and pull requests.

## Got a question, problem, or feature request?

The documentation is a good place to start.

Feel free to [add an issue](https://github.com/tmotagam/sqlite-electron/issues) if those don't help!

## Want to submit a change?

If you're not sure whether your change will be welcomed, [add an issue](https://github.com/tmotagam/sqlite-electron/issues) to ask.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

sqlite-electron module for electron and nodejs
Copyright (C) 2022-2023 Motagamwala Taha Arif Ali
Copyright (C) 2020-2024 Motagamwala Taha Arif Ali

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

sqlite-electron Copyright (C) 2022-2023 Motagamwala Taha Arif Ali
sqlite-electron Copyright (C) 2020-2024 Motagamwala Taha Arif Ali
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down
143 changes: 130 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

Sqlite Electron is a module for electron to use sqlite3 database without rebuilding it supports Windows (x64, x32) and Linux (x64). It supports ESM and CJS.

Several bugs fixed and now all data types are supported
Changes:

* The setdbPath now supports the [SQLite URI](https://www.sqlite.org/uri.html)

* The executeQuery API has been changed.

* The fetch API has been added for fetching the data from the database.

* The fetch API will now return the data in the object format where the keys will be column and the values will be the data point for that column in the database.

* Also when using typescript you can define the type of the object that will be returned when using the fetch API.

## Installation

Expand Down Expand Up @@ -51,10 +61,13 @@ executeQuery(

| Api | Description |
| ------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------: |
| setdbPath(path='') | It opens or creates the database for operation |
| executeQuery(Query = '', fetch = '', values = []) | It Executes single query with fetch and values the fetch must be in string eg:- 'all', '1','2'... '' values must be array |
| executeMany(Query = '', values = []) | It executes single query with multiple values |
| executeScript(scriptName = '') | It execute the sql script scriptName must be name of the script or the script itself |
| setdbPath(path='', isuri=false) | It opens or creates the database for operation now supports the InMemory database and also SQLite URI format |
| executeQuery(query = '', values = []) | It Executes single query with values they must be array |
| executeMany(query = '', values = []) | It executes single query with multiple values |
| executeScript(scriptname = '') | It execute the sql script scriptName must be name of the script or the script itself |
| fetchAll(query = '', values = []) | It fetches all the values that matches the query. The values can also be given for the query using values array |
| fetchOne(query = '', values = []) | It fetches only one value that matches the query. The values can also be given for the query using values array |
| 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 |

## Usage

Expand Down Expand Up @@ -82,7 +95,7 @@ app.on("window-all-closed", () => {

This is a function for opening a existing database or creating a new database for operation.

Call this function before calling the other 3 functions.
Call this function before calling the other 6 functions.

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
Expand All @@ -104,7 +117,7 @@ ipcMain.handle("databasePath", async (event, dbPath) => {
});
```

Now you can also create In-memory database like this.
You can create an In-memory database like this.

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
Expand All @@ -126,9 +139,31 @@ ipcMain.handle("createInMemoryDatabase", async () => {
});
```

Now you can also use the SQLite URI format like this.

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
const sqlite = require("sqlite-electron");

function createWindow() {
// Your Code
}
app.whenReady().then(() => {
// Your Code
});

app.on("window-all-closed", () => {
// Your Code
});

ipcMain.handle("createDatabaseusingURI", async () => {
return await sqlite.setdbPath("file:tutorial.db?mode:rw", isuri=true);
});
```

### executeQuery

This is the function for executing any single query eg: 'SELECT \* FROM sqlite_main' you can give values through value array and tell the function to fetch data by specifying the fetch parameter eg: "all", 1, 2, 3, .., infinity.
This is the function for executing any single query eg: 'INSERT INTO tutorial (x) VALUES (?)' you can give values through the values array.

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
Expand All @@ -149,8 +184,92 @@ ipcMain.handle("databasePath", async (event, dbPath) => {
return await sqlite.setdbPath(dbPath);
});

ipcMain.handle("executeQuery", async (event, query, fetch, value) => {
return await sqlite.executeQuery(query, fetch, value);
ipcMain.handle("executeQuery", async (event, query, values) => {
return await sqlite.executeQuery(query, values);
});
```

### fetchAll

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', ...}].

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
const sqlite = require("sqlite-electron");

function createWindow() {
// Your Code
}
app.whenReady().then(() => {
// Your Code
});

app.on("window-all-closed", () => {
// Your Code
});

ipcMain.handle("databasePath", async (event, dbPath) => {
return await sqlite.setdbPath(dbPath);
});

ipcMain.handle("fetchAll", async (event, query, values) => {
return await sqlite.fetchAll(query, values);
});
```

### fetchOne

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', ...}.

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
const sqlite = require("sqlite-electron");

function createWindow() {
// Your Code
}
app.whenReady().then(() => {
// Your Code
});

app.on("window-all-closed", () => {
// Your Code
});

ipcMain.handle("databasePath", async (event, dbPath) => {
return await sqlite.setdbPath(dbPath);
});

ipcMain.handle("fetchOne", async (event, query, values) => {
return await sqlite.fetchOne(query, values);
});
```

### fetchMany

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', ...}].

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
const sqlite = require("sqlite-electron");

function createWindow() {
// Your Code
}
app.whenReady().then(() => {
// Your Code
});

app.on("window-all-closed", () => {
// Your Code
});

ipcMain.handle("databasePath", async (event, dbPath) => {
return await sqlite.setdbPath(dbPath);
});

ipcMain.handle("fetchMany", async (event, query, size, values) => {
return await sqlite.fetchMany(query, size, values);
});
```

Expand All @@ -160,8 +279,6 @@ This is the function for executing query with multiple values.

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]]) .

Fetch is not available in this function

```javascript
const { app, BrowserWindow, ipcMain } = require("electron");
const sqlite = require("sqlite-electron");
Expand Down Expand Up @@ -228,7 +345,7 @@ ipcMain.handle("executeScript", async (event, scriptpath) => {

## Example

[See sqlite-electron in action using electron 25.0.1](https://github.com/tmotagam/sqlite-electron/tree/master/example)
[See sqlite-electron in action using electron 28.0.0](https://github.com/tmotagam/sqlite-electron/tree/master/example)

## Contributing

Expand Down
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security issue reporting & disclosure process

If you feel you have found a security issue or concern with sqlite-electron, please reach out to Me.

Email Me at <tahaar5321@gmail.com> .

I will try to communicate in a timely manner and address your concerns.
4 changes: 2 additions & 2 deletions example/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

sqlite-electron-demo for showing sqlite-electron in action using electron 15.3.0
Copyright (C) 2022 Motagamwala Taha Arif Ali
Copyright (C) 2022-2024 Motagamwala Taha Arif Ali

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

sqlite-electron-demo Copyright (C) 2022 Motagamwala Taha Arif Ali
sqlite-electron-demo Copyright (C) 2022-2024 Motagamwala Taha Arif Ali
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand Down

0 comments on commit 7d7f2d9

Please sign in to comment.