mssql~ MSSQLClient

MSSQLClient is a client for MS SQL database. Internally client uses denisenkom/go-mssqldb driver.

Constructor

new MSSQLClient()

Methods

Connect(host, port, username, password) → {bool}

Connect connects to MS SQL database using given credentials. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns.
Parameters:
NameTypeDescription
hoststringThe host of the MS SQL database.
portintThe port of the MS SQL database.
usernamestringThe username to connect to the MS SQL database.
passwordstringThe password to connect to the MS SQL database.
Throws:
- The error encountered during connection.
Type
error
Returns:
- The status of the connection.
Type: 
bool
Example
let m = require('nuclei/mssql');
let c = m.MSSQLClient();
let isConnected = c.Connect('localhost', 1433, 'username', 'password');

ConnectWithDB(host, port, username, password, dbName) → {bool}

ConnectWithDB connects to MS SQL database using given credentials and database name. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns.
Parameters:
NameTypeDescription
hoststringThe host of the MS SQL database.
portintThe port of the MS SQL database.
usernamestringThe username to connect to the MS SQL database.
passwordstringThe password to connect to the MS SQL database.
dbNamestringThe name of the database to connect to.
Throws:
- The error encountered during connection.
Type
error
Returns:
- The status of the connection.
Type: 
bool
Example
let m = require('nuclei/mssql');
let c = m.MSSQLClient();
let isConnected = c.ConnectWithDB('localhost', 1433, 'username', 'password', 'myDatabase');

IsMssql(host, port) → {bool}

IsMssql checks if the given host is running MS SQL database. If the host is running MS SQL database, it returns true. If the host is not running MS SQL database, it returns false.
Parameters:
NameTypeDescription
hoststringThe host to check.
portintThe port to check.
Throws:
- The error encountered during the check.
Type
error
Returns:
- The status of the check.
Type: 
bool
Example
let m = require('nuclei/mssql');
let c = m.MSSQLClient();
let isMssql = c.IsMssql('localhost', 1433);