
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
@tediousjs/connection-string
Advanced tools
@tediousjs/connection-string is a utility package designed to parse and format connection strings for use with the Tedious library, which is a TDS (Tabular Data Stream) protocol implementation for Node.js. This package helps in managing and manipulating connection strings for SQL Server databases.
Parsing Connection Strings
This feature allows you to parse a connection string into a configuration object that can be used with the Tedious library. The `parseConnectionString` function takes a connection string and returns an object with the parsed details.
const { parseConnectionString } = require('@tediousjs/connection-string');
const connectionString = 'Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;';
const config = parseConnectionString(connectionString);
console.log(config);
Formatting Connection Strings
This feature allows you to format a configuration object into a connection string. The `formatConnectionString` function takes a configuration object and returns a connection string that can be used to connect to a SQL Server database.
const { formatConnectionString } = require('@tediousjs/connection-string');
const config = {
server: 'myServerAddress',
authentication: {
type: 'default',
options: {
userName: 'myUsername',
password: 'myPassword'
}
},
options: {
database: 'myDataBase'
}
};
const connectionString = formatConnectionString(config);
console.log(connectionString);
The `pg-connection-string` package is used for parsing and formatting PostgreSQL connection strings. It provides similar functionality to @tediousjs/connection-string but is specifically designed for PostgreSQL databases. It can parse connection strings into configuration objects and format configuration objects back into connection strings.
The `connection-string` package is a more general-purpose library for parsing and formatting connection strings for various databases. It supports multiple database types, including PostgreSQL, MySQL, and SQL Server, making it more versatile compared to @tediousjs/connection-string, which is specific to SQL Server.
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.
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"
}
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
FAQs
SQL ConnectionString parser
The npm package @tediousjs/connection-string receives a total of 723,106 weekly downloads. As such, @tediousjs/connection-string popularity was classified as popular.
We found that @tediousjs/connection-string demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.