Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cityssm/mssql-multi-pool
A simple way to manage connections to multiple SQL Server databases using the Node.js Tedious driver.
https://github.com/cityssm/mssql-multi-pool
connection-pool hacktoberfest mssql node-mssql pool sql tedious
Last synced: 3 months ago
JSON representation
A simple way to manage connections to multiple SQL Server databases using the Node.js Tedious driver.
- Host: GitHub
- URL: https://github.com/cityssm/mssql-multi-pool
- Owner: cityssm
- License: mit
- Created: 2020-10-21T16:25:32.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-25T15:25:00.000Z (3 months ago)
- Last Synced: 2024-09-29T14:41:43.169Z (3 months ago)
- Topics: connection-pool, hacktoberfest, mssql, node-mssql, pool, sql, tedious
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@cityssm/mssql-multi-pool
- Size: 688 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# mssql-multi-pool
[![npm](https://img.shields.io/npm/v/@cityssm/mssql-multi-pool)](https://www.npmjs.com/package/@cityssm/mssql-multi-pool)
[![Maintainability](https://img.shields.io/codeclimate/maintainability/cityssm/mssql-multi-pool)](https://codeclimate.com/github/cityssm/mssql-multi-pool/maintainability)
[![codecov](https://codecov.io/gh/cityssm/mssql-multi-pool/branch/main/graph/badge.svg?token=865Y3ZDNMC)](https://codecov.io/gh/cityssm/mssql-multi-pool)
[![Coverage Testing](https://github.com/cityssm/mssql-multi-pool/actions/workflows/coverage.yml/badge.svg)](https://github.com/cityssm/mssql-multi-pool/actions/workflows/coverage.yml)
[![DeepSource](https://app.deepsource.com/gh/cityssm/mssql-multi-pool.svg/?label=active+issues&show_trend=true&token=4Yz1B7bqP-sZ50AZnjXpoEos)](https://app.deepsource.com/gh/cityssm/mssql-multi-pool/)A simple way to manage connections to multiple SQL Server databases using the Node.js Tedious driver.
## Why?
The fantastic [node-mssql](https://github.com/tediousjs/node-mssql) package
provides an easy and reliable way to connect to _one_ SQL Server instance.Connecting to multiple SQL Server instances is where things get trickier.
Not too tricky, but it is more involved as you can't rely on the global pool.
There is some sample code in the [node-mssql README](https://github.com/tediousjs/node-mssql) that shows how to do it.
This project implements that sample code.## Installation
```sh
npm install @cityssm/mssql-multi-pool
```## Usage
Replace the `connect(config);` command from the `mssql` package
with the `connect(config);` command from the `@cityssm/mssql-multi-pool` package.If the configuration object describes an unseen database, a new pool is made.
Otherwise, the previously made pool is used.```javascript
import * as sql from '@cityssm/mssql-multi-pool';(async function () {
try {
let pool = await sql.connect(config)// Use the `mssql` package like before.
} catch (e) {}
})()
```