diff --git a/README.md b/README.md index 96da7ab..9a29134 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Options: -p, --pass Password to use for authentication -o, --port Port to connect to -t, --timeout Connection timeout in ms + -D, --dsn Classic DSN connection string -d, --database Database to connect to -q, --query The query to execute -v, --tdsVersion Version of tds protocol to use [7_4, 7_2, 7_3_A, 7_3_B, 7_4] @@ -48,6 +49,13 @@ To connect to a SQL Server instance in Azure invoke mssql as follows mssql -s abcdef.database.windows.net -u username@abcdef -p thepassword -d mydatabase -e ``` +A classic style DSN connection string may be used in lieu of all other +options + +``` bash +mssql -D "Server=localhost,1433;UID=DOMAIN\\user;PWD=password" +``` + You will get a prompt as follows: ```bash Connecting to abcdef.database.windows.net...done diff --git a/lib/options.js b/lib/options.js index 498dc3c..602794b 100644 --- a/lib/options.js +++ b/lib/options.js @@ -27,6 +27,7 @@ .option('-o, --port ', 'Port to connect to') .option('-t, --timeout ', 'Connection timeout in ms') .option('-T, --requestTimeout ', 'Request timeout in ms') + .option('-D, --dsn ', 'DSN connection string') .option('-d, --database ', 'Database to connect to') .option('-q, --query ', 'The query to execute') .option('-v, --tdsVersion ', 'Version of tds protocol to use [7_4, 7_2, 7_3_A, 7_3_B, 7_4]') @@ -39,7 +40,7 @@ this.env = env; this.args = {}; _.extend(this.args, _.pick(program, 'server', 'user', 'pass', - 'port', 'requestTimeout', 'timeout', + 'port', 'requestTimeout', 'timeout', 'dsn', 'database', 'query', 'tdsVersion', 'encrypt', 'format', 'config')); @@ -74,6 +75,7 @@ user: env.SQLCLI_USER || 'sa', pass: env.SQLCLI_PASSWORD, server: env.SQLCLI_SERVER || 'localhost', + dsn: env.SQLCLI_DSN, database: env.SQLCLI_DATABASE, port: env.SQLCLI_PORT, timeout: env.SQLCLI_TIMEOUT, @@ -84,7 +86,8 @@ config = _.extend({}, defaults, config, args); - var connectInfo = { + var connectInfo = !config.dsn + ? { user: config.user, password: config.pass, server: config.server, @@ -100,7 +103,8 @@ max: 1, min: 1 } - }; + } + : config.dsn ; return connectInfo; }