Socket
Socket
Sign inDemoInstall

@tediousjs/connection-string

Package Overview
Dependencies
0
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tediousjs/connection-string

SQL ConnectionString parser


Version published
Weekly downloads
463K
increased by8.52%
Maintainers
2
Install size
36.1 kB
Created
Weekly downloads
 

Changelog

Source

0.5.0 (2023-08-09)

Features

  • add connection string builder (369a63f)

Readme

Source

Connection String Parser

npm version Lint, Test & Release

This node library is designed to allow the parsing of Connection Strings see https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring

The library also provides the ability to parse SQL Connection Strings.

Usage

Parsing connection strings

The library comes with a generic connection string parser that will parse through valid connections strings and produce a key-value map of the entries in that string. No additional validation is performed.

const { parseConnectionString } = require('@tediousjs/connection-string');

const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';

const parsed = parseConnectionString(connectionString);

console.log(parsed);

Output to the console will be:

{
  "User id": "user",
  "password": "password",
  "initial catalog": "AdventureWorks",
  "server": "MySqlServer"
}

Parsing SQL connection strings

There is a specific helper for parsing SQL connection strings and this comes with a value normaliser and validation. It also has an option to "canonicalise" the properties. For many properties in an SQL connections string, there are aliases, when canonical properties are being used, these aliases will be returned as the canonical property.

const { parseSqlConnectionString } = require('@tediousjs/connection-string');

const connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';

const parsed = parseSqlConnectionString(connectionString, true);

console.log(parsed);

Output to console will be:

{
  "user id": "user",
  "password": "password",
  "initial catalog": "AdventureWorks",
  "data source": "MySqlServer"
}

NB: The Server property from the connection string has been re-written to the value Data Source

Keywords

FAQs

Last updated on 09 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc