# mysql-sync-query

> Extends the mysql package to support executing queries synchronously.

Latest version **1.0.4** (published 2020-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install mysql-sync-query
pnpm add mysql-sync-query
yarn add mysql-sync-query
bun add mysql-sync-query
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-02-18 |
| First published | 2020-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Siavash Ashkiani |
| Maintainers | ashkiani |
| Keywords | mysql, sync, await, query |

## Links

- npm: https://www.npmjs.com/package/mysql-sync-query
- Repository: https://github.com/ashkiani/mysql-sync-query
- Homepage: https://github.com/ashkiani/mysql-sync-query#readme
- Issues: https://github.com/ashkiani/mysql-sync-query/issues
- npm.io page: https://npm.io/package/mysql-sync-query

## Dependencies (1)

- [mysql](https://npm.io/package/mysql.md) ^2.18.1

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-02-18
- 1.0.3 — 2020-02-17
- 1.0.2 — 2020-02-17
- 1.0.1 — 2020-02-17
- 1.0.0 — 2020-02-17

## README

# mysql-sync-query

#### 02/17/2020

#### By Siavash Ashkiani
​
## Description
Extends the mysql package to  
1- Promisify the database connection object.   
2- Provide a method for executing queries synchronously.  

## Setup/Installation Requirements
​
* Run command: ```npm install mysql-sync-query```
* Declare a variable/constant to require the installed package e.g. 
```
let db = require("mysql-sync-query");
```
* The defined variable in the last step represents a class with a constructor that takes an existing database name. e.g. 
```
let databaseObject = new db("employees_db");
```

## Methods
#### connectLocal
Connects Node to an existing local MySQL server.
Parameters:
* host - host name e.g. localHost
* port - database connection port e.g. 3306
* user - database login username
* password - database login password

#### connectRemote
Connects Node to an existing remote MySQL server.
Parameters:
* URL - e.g. ```process.env.JAWSDB_URL```

#### executeQuery
Executes the input query and returns the affected rows  
Parameters:  
* textQuery - the SQL query string e.g. ```"SELECT * FROM table_name"```  
Returns:  
* a JSON object that contains database records.

#### disconnect
Terminates the connection.​

## Example
```
const db = require("mysql-sync-query");  
const dbObj = new db("employees_db");  

async function start() {  
    dbObj.connectLocal("localHost", 3306, "user", "password");  
    try {  
        let res = await dbObj.executeQuery("SELECT * FROM employee");  
        console.log(res);  
    }  
    catch (err) {  
        console.log(err);  
    }  
    finally {  
        dbObj.disconnect();  
    }  
}  
  
start();  
```
## Known Bugs

None - at this time​.

​
## Support and contact details
​
Please email us for further questions at ashkiani@yahoo.com
​
## Technologies Used
​
Node.js, MySQL

​
## Contribution Guidlines 
​
Direct link to package: https://www.npmjs.com/package/mysql-sync-query
​
### License
​
This software is licensed under MIT license.

---
_Source: https://npm.io/package/mysql-sync-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
