{"id":28391465,"url":"https://github.com/tediousjs/connection-string","last_synced_at":"2026-04-10T05:37:44.204Z","repository":{"id":37863123,"uuid":"253829288","full_name":"tediousjs/connection-string","owner":"tediousjs","description":"A connection string parsing library","archived":false,"fork":false,"pushed_at":"2025-06-16T08:16:14.000Z","size":1185,"stargazers_count":9,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-16T09:32:07.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tediousjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-07T15:07:39.000Z","updated_at":"2025-06-16T08:13:55.000Z","dependencies_parsed_at":"2024-06-18T16:41:56.154Z","dependency_job_id":"e315ee7e-c290-4ce6-8a3a-09e5df5d8fa1","html_url":"https://github.com/tediousjs/connection-string","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/tediousjs/connection-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tediousjs%2Fconnection-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tediousjs%2Fconnection-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tediousjs%2Fconnection-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tediousjs%2Fconnection-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tediousjs","download_url":"https://codeload.github.com/tediousjs/connection-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tediousjs%2Fconnection-string/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260135774,"owners_count":22964135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-31T09:39:05.675Z","updated_at":"2026-04-10T05:37:39.151Z","avatar_url":"https://github.com/tediousjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connection String Parser\n\n[![npm version](https://badge.fury.io/js/@tediousjs%2Fconnection-string.svg)](https://www.npmjs.com/package/@tediousjs/connection-string)\n[![Lint, Test \u0026 Release](https://github.com/tediousjs/connection-string/actions/workflows/nodejs.yml/badge.svg)](https://github.com/tediousjs/connection-string/actions/workflows/nodejs.yml)\n\nThis 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\n\nThe library also provides the ability to parse SQL Connection Strings.\n\n# Usage\n\n## Parsing connection strings\n\nThe library comes with a generic connection string parser that will parse through valid connection strings and produce a key-value\nreadonly Map of the entries in that string. No additional validation is performed.\n\n```js\nconst { parse } = require('@tediousjs/connection-string');\n\nconst connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';\n\nconst parsed = parse(connectionString);\n\nconsole.log(parsed);\n```\n\nOutput to the console will be:\n\n```\nMap(4) {\n  'user id' =\u003e 'user',\n  'password' =\u003e 'password',\n  'initial catalog' =\u003e 'AdventureWorks',\n  'server' =\u003e 'MySqlServer'\n}\n```\n\n## Parsing SQL connection strings\n\nSQL connection strings can be parsed to a JSON object using the `toSchema()` method and the provided\n`MSSQL_SCHEMA`.\n\n```js\nconst { parse, MSSQL_SCHEMA } = require('@tediousjs/connection-string');\n\nconst connectionString = 'User ID=user;Password=password;Initial Catalog=AdventureWorks;Server=MySqlServer';\n\nconst parsed = parse(connectionString);\n\nconsole.log(parsed.toSchema(MSSQL_SCHEMA));\n```\n\nOutput to console will be:\n\n```json\n{\n  \"data source\": \"MySqlServer\",\n  \"initial catalog\": \"AdventureWorks\",\n  \"password\": \"password\",\n  \"user id\":\"user\"\n}\n```\n\nNB: The `Server` property from the connection string has been re-written to the value `Data Source`\n\n## Custom schemas\n\nIf you need to parse a connection string into a custom schema, the format is as follows:\n\n```ts\nimport { parse } from '@tediousjs/connection-string';\n\n// a keyed map of name =\u003e config\nconst schema = {\n    'a string': {\n        type: 'string',\n        default: 'a default value',\n        aliases: ['other', 'allowed', 'names'],\n    },\n    'a number': {\n        type: 'number',\n        default: 123,\n    },\n    'a boolean': {\n        type: 'boolean',\n        default: true,\n    },\n};\n\nconst parsed = parse('a string=test;a number=987;a boolean=false;other value=missing');\nconsole.log(parsed.toSchema(schema));\n```\n\nOutput:\n\n```json\n{\n  \"a string\": \"test\",\n  \"a number\": 987,\n  \"a boolean\": false\n}\n```\n\n## Accessing properties\n\nThe parsed connection string object is a readonly `Map` with an overloadded `get()` method allowing\ncoercion of the value:\n\n```ts\nimport { parse } from '@tediousjs/connection-string';\nconst parsed = parse('a string=test;a number=987;a boolean=false;other value=missing');\n// all values are strings by default\nconsole.log(parsed.get('a number')); // \"987\"\n// values can be coersed to an expected type\nconsole.log(parsed.get('a number', 'number')); // 987\n// coersion will be permissive in its type coersion\nconsole.log(parsed.get('a number', 'boolean')); // true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftediousjs%2Fconnection-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftediousjs%2Fconnection-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftediousjs%2Fconnection-string/lists"}