ts-host-parser
v1.0.0
Published
Small package to parse JDBC, ODBC or Amazon Redshift connection strings
Downloads
1,010
Readme
Parsing Connection Strings
ts-host-parser currently parses/supports 3 different connection strings which are in JDBC, ODBC or host:port format.
It support Typescript, so it has typings.
Example connection strings:
JDBC
jdbc:redshift://test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com:5439/my_database_name
ODBC
Driver={Amazon Redshift (x64)}; Server=test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com; Database=my_database_name; UID=my_user_name; PWD=insert_your_master_user_password_here; Port=5439
host:port
test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com:5439
Usage ( Typescript )
Example for JDBC string;
let connectionString = "jdbc:redshift://test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com:5439/my_database_name";
let result = TSHostParser.parse(connectionString);
console.log(result.Host); // prints "test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com"
console.log(result.Port); // prints "5439"
console.log(result.DatabaseName); // prints "my_database_name"
Example for ODBC string;
let connectionString = "Driver={Amazon Redshift (x64)}; Server=test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com; Database=my_database_name; UID=my_user_name; PWD=insert_your_master_user_password_here; Port=5439";
let result = TSHostParser.parse(connectionString);
console.log(result.Host); // prints "test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com"
console.log(result.Port); // prints "5439"
console.log(result.DatabaseName); // prints "my_database_name"
console.log(result.Password); // prints "insert_your_master_user_password_here"
console.log(result.Username); // prints "my_user_name"
Example for host:port string;
let connectionString = "test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com:5439";
let result = TSHostParser.parse(connectionString);
console.log(result.Host); // prints "test-instance-redshift.xx000aaa0bbb.us-east-1.redshift.amazonaws.com"
console.log(result.Port); // prints "5439"