parse-connection-string
v1.0.1
Published
JS/TS library for parsing SQL Server connection strings
Downloads
6
Readme
parse-connection-string
parse-connection-string
takes a standard MS SQL server connection string, parses it and converts into a format suitable for Knex.
API
import parse from "parse-connection-string";
import knex from "knex";
const connStr = process.env.MSSQL_CONNECTION_STRING;
const config = parse(connStr).toKnexConfig();
const db = knex({
client: "mssql",
connection: config
});
Simply pass your connection string into the parseConnectionString
function and call one of the output functions on the result to get the options in the format you want. At the moment there's only toKnexConfig()
. Other formats will be added as necessary.
Running Tests
Run yarn test
in this directory to run unit tests.