Registry / database / viva-server-mssql

viva-server-mssql

JSON →
library3.1.1jsnpmunverified

viva-server-mssql is a library for working with Microsoft SQL Server, providing a class-based API for connection management, query execution, transaction handling, and data manipulation (e.g., clone_table). The current stable version is 3.1.1, released primarily for Node.js environments. It uses the 'mssql' package as a peer dependency and supports both callback-based and promise-based patterns. Key differentiators include built-in action scheduling, timezone offset handling, and performance monitoring. The library is designed for server-side applications requiring direct MSSQL interaction with fine-grained control over connections and execution options.

npm install viva-server-mssql
INSTALL
IMPORT
SIG · VIVA-SERVER-MSSQL
V
viva-server-mssql
databasejavascriptv3.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server_mssql
import { Server_mssql } from 'viva-server-mssql'
const Server_mssql = require('viva-server-mssql')
The package is ESM-only since v3. CommonJS require will fail with ERR_REQUIRE_ESM.
clone_table
import { clone_table } from 'viva-server-mssql'
import clone_table from 'viva-server-mssql'
Functions are named exports, not default exports.
noname_row_beautify
import { noname_row_beautify } from 'viva-server-mssql'
import { noname_row_beautify } from 'viva-server-mssql/dist/index.js'
Do not add subpath imports; main entry handles all named exports.

Creates a Server_mssql instance, connects to MSSQL, executes a simple query, and logs the result.

import { Server_mssql } from 'viva-server-mssql'; const server = new Server_mssql(); const config = { server: process.env.MSSQL_HOST ?? 'localhost', database: process.env.MSSQL_DB ?? 'test', user: process.env.MSSQL_USER ?? 'sa', password: process.env.MSSQL_PASSWORD ?? '', options: { encrypt: false } }; server.init(config, (err) => { if (err) { console.error('Connection failed', err); return; } server.exec('SELECT GETDATE() AS now', (err, result) => { if (err) console.error(err); else console.log(result.recordset); }); });
Debug
Known issues
breakingPackage changed from CommonJS to pure ESM in v3.0.0. require() will throw ERR_REQUIRE_ESM.
fix
Use import syntax or dynamic import(). Alternatively, downgrade to v2.x for CommonJS support.
affects: >=3.0.0
deprecatedThe class 'Server_mssql' constructor does not accept arguments in v3. Connection config must be passed to .init().
fix
Call new Server_mssql() without arguments, then call .init(config).
affects: >=3.0.0
gotchaAll callback parameters follow Node.js error-first convention. If callback is omitted, exec() returns a Promise (since v2.5).
fix
For promise usage, omit the callback and await the result: const result = await server.exec('SELECT 1').
affects: >=2.5.0
breakingThe 'mssql' peer dependency version was bumped from ^7 to ^8 in v3.1.0. Incompatible with older tedious drivers.
fix
Update mssql to version 8.x in your project dependencies.
affects: >=3.1.0
gotchaThe .init() method will fail silently (callback with error) if the config object is missing required keys like 'server' or 'database'.
fix
Always validate config before .init() and handle error in callback.
affects: >=3.0.0
deprecatedFunction 'clone_table' is experimental and may change signature in future minor versions.
fix
Check changelog and pin version for stable use.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to require() the package which is ESM-only since v3.
fix
Change require('viva-server-mssql') to import { Server_mssql } from 'viva-server-mssql'.
TypeError: server.exec is not a function
Forgetting to await server.init() before calling exec when using promises.
fix
Ensure init completes before exec: await server.init(config); then await server.exec(...);
error: (Node:1234) [MSSQL] ConnectionError: Failed to connect to localhost:1433 - getaddrinfo ENOTFOUND
MSSQL server is not reachable or config.server is incorrect.
fix
Check hostname, port, and network connectivity. Ensure SQL Server is running and accepts remote connections.
TypeError: server.exec is not a function (but server.init works)
Using an older v2.x API where exec was named differently (e.g., executeQuery).
fix
Upgrade to v3 and use exec(); check migration guide for renamed methods.
Upgrade
Version history
3.1.1latest on npm
Audit
Dependencies
mssqlrequiredRequired as a peer dependency for SQL Server connectivity via tedious or other driver.
Agent activity
18 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources