# kmk-mssqlclient

> README.md

Latest version **0.0.16** (published 2020-02-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install kmk-mssqlclient
pnpm add kmk-mssqlclient
yarn add kmk-mssqlclient
bun add kmk-mssqlclient
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.16 |
| Published | 2020-02-04 |
| First published | 2019-07-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 80.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | kamikai |
| Maintainers | kamikai |
| Keywords | sql, mssql, client, database, db, node |

## Links

- npm: https://www.npmjs.com/package/kmk-mssqlclient
- Repository: https://github.com/neokamikai/kmk-node-sqlclient
- Homepage: https://github.com/neokamikai/kmk-node-sqlclient#readme
- Issues: https://github.com/neokamikai/kmk-node-sqlclient/issues
- npm.io page: https://npm.io/package/kmk-mssqlclient

## Dependencies (2)

- [mssql](https://npm.io/package/mssql.md) ^5.1.0
- [@types/mssql](https://npm.io/package/@types/mssql.md) ^6.0.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.0.16 (latest) — 2020-02-04
- 0.0.15 — 2020-01-21
- 0.0.14 — 2020-01-21
- 0.0.13 — 2020-01-21
- 0.0.12 — 2020-01-21
- 0.0.11 — 2020-01-21
- 0.0.10 — 2020-01-21
- 0.0.9 — 2020-01-21
- 0.0.8 — 2020-01-19
- 0.0.7 — 2020-01-19
- 0.0.6 — 2020-01-19
- 0.0.5 — 2019-10-15
- 0.0.4 — 2019-10-15
- 0.0.3 — 2019-07-19
- 0.0.2 — 2019-07-19
- … 1 more at https://npm.io/package/kmk-mssqlclient/versions

## README

# kmk-mssqlclient

### Installation

`npm install kmk-mssqlclient`


### Usage

***Initialization***

```javascript
const SqlClient = require('kmk-mssqlclient');
const cn = new SqlClient();
cn.setConfig({
	user: 'username',
	password: 'password',
	server: 'server',
	database: 'database',
	options: {
		encrypt: false
	}
});
```
***Connecting***
```javascript
cn.connect()
.catch(e => {
	console.log(e);
})
.then(() => {
	console.log('connected');
})

/* OR */

SqlClient.open({
	user: 'username',
	password: 'password',
	server: 'server',
	database: 'database',
	options: {
		encrypt: false
	}
}, (err, client) => {
	if(err) console.log(err);
	else console.log(client);
})

```
***Connecting using async/await mode***
```javascript
(async () => {
	try{
		await cn.connect();
		console.log('connected');
	}
	catch(e){
		console.log(e);
	}
})()
```

***Querying data***
```javascript
cn.query('select * from table')
.catch(e => {
	console.log(e);
})
.then(result => {
	console.log(result);
})
```

***Querying data using async/await mode***
```javascript
(async () => {
	try{
		let result = await cn.query('select * from table');
		console.log(result);
	}
	catch(e){
		console.log(e);
	}
})()
```


### Methods
<table class="table">
	<thead>
		<tr>
			<th>Method Name</th>
			<th>Returns</th>
			<th>Parameters</th>
			<th>Description</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>connect</td>
			<td>Promise&lt;void&lt;T&gt;&gt;</td>
			<td>(void)</td>
			<td>Connects to a MS SQL Server</td>
		</tr>
		<tr>
			<td>query&lt;T&gt;</td>
			<td>Promise&lt;IQueryResult&lt;T&gt;&gt;</td>
			<td>(sqlCommandStatement: string, ...optionalParams: any[])</td>
			<td>Executes a sql query and returns recordsets and rows affected</td>
		</tr>
		<tr>
			<td>executeRowSet&lt;T&gt;</td>
			<td>Promise&lt;Array&lt;T&gt;&gt;</td>
			<td>(sqlCommandStatement: string, ...optionalParams: any[])</td>
			<td>Executes a query and returns the first rowSet for that query</td>
		</tr>
		<tr>
			<td>executeLastRowSet&lt;T&gt;</td>
			<td>Promise&lt;Array&lt;T&gt;&gt;</td>
			<td>(sqlCommandStatement: string, ...optionalParams: any[])</td>
			<td>Executes a query and returns the last rowSet for that query</td>
		</tr>
		<tr>
			<td>executeRowSets</td>
			<td>Promise&lt;Array<Array<any>>&gt;</td>
			<td>(sqlCommandStatement: string, ...optionalParams: any[])</td>
			<td>Executes a query and returns all rowSets for that query</td>
		</tr>
		<tr>
			<td>fetchRow&lt;T&gt;</td>
			<td>Promise&lt;T&gt;</td>
			<td>(sqlCommandStatement: string)</td>
			<td>Executes a query and returns the first row from the first rowSet for that query</td>
		</tr>
		<tr>
			<td>fetchColumn</td>
			<td></td>
			<td>(sqlCommandStatement: string, index: number | string = 0)</td>
			<td>Executes a query and returns a specific field (index or name) from the first row from the first rowSet for that query</td>
		</tr>
		<tr>
			<td>executeNonQuery</td>
			<td>Promise&lt;number&gt;</td>
			<td>(sqlCommandStatement: string, ...optionalParams: any[])</td>
			<td>Executes a sql statement and returns affected row count</td>
		</tr>
		<tr>
			<td>getLastsqlCommandStatement</td>
			<td>string</td>
			<td>(void)</td>
			<td>Returns the last sqlCommandStatement executed</td>
		</tr>
	</tbody>
</table>

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