Registry / database / mssql-connection-string

mssql-connection-string

JSON →
library0.3.2jsnpmunverified

A small TypeScript library for parsing MS SQL Server connection strings into configuration objects compatible with knex. At version 0.3.2, it extracts host, port, database, user, and password from standard connection strings. Differentiators: built-in support for handling email-like User IDs (extracts login), optional protocol and port in Data Source, and ESM + CJS exports. The library is stable but has low activity and no recent updates. Works in Node.js environments.

npm install mssql-connection-string
INSTALL
IMPORT
SIG · MSSQL-CONNECTION-S
M
mssql-connection-string
databasejavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import parse from 'mssql-connection-string'
✗ const parse = require('mssql-connection-string').default
The default export is the parse function. In TypeScript, use default import.
default
✓ const parse = require('mssql-connection-string')
✗ const { parse } = require('mssql-connection-string')
CommonJS users should assign the whole module to a variable; there is no named export.
type
✓ import type { ConnectionConfig, KnexConfig } from 'mssql-connection-string'
Only available in TypeScript with ESM-like imports; types are exported from the package.

Parses a typical MS SQL Server connection string and outputs configuration for knex.

import parse from 'mssql-connection-string'; const connStr = 'Data Source=tcp:example.com,1433;Initial Catalog=mydb;User Id=user@domain.com;Password=secret;'; const config = parse(connStr); console.log(config); // { // host: 'example.com', // options: { database: 'mydb', encrypt: true, port: '1433' }, // password: 'secret', // user: 'user' // }
Debug
Known issues
gotchaThe package does not validate connection string syntax; invalid strings may cause unexpected results.
fix
Ensure the connection string follows standard MS SQL format before parsing.
affects: *
gotcha'encrypt' is hardcoded to true in the output; there is no option to change it.
fix
If encryption is not desired, override the 'options.encrypt' field after parsing.
affects: *
gotchaIf 'User Id' contains an email address, only the part before '@' is used as the user. This may break authentication if the actual expected user is the full email.
fix
Provide a non-email User Id or modify the library source if full email is required.
affects: *
gotchaThe package is not actively maintained; last release was in 2019.
fix
Consider alternatives like tedious or mssql for active support.
affects: *
Errors
Common errors & fixes
TypeError: parse is not a function
Incorrect import in CommonJS: using destructuring instead of assigning the default export.
fix
const parse = require('mssql-connection-string');
Cannot find module 'mssql-connection-string' or its corresponding type declarations.
Missing npm install or type definitions not recognized.
fix
npm install mssql-connection-string and ensure tsconfig includes node_modules.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
mssql-connection-string — npm install mssql-connection-string · libregistry