npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mssql-conn

v0.0.6

Published

Microsoft SQL Connection Helper

Downloads

44

Readme

MSSQL Connection Helper

npm npm

Módulo Node.js para facilitar a comunicação com o Microsoft SQL Server

Instalação e requisitos

Necessário Node.js para instalar e Microsoft SQL Server para executar

npm install mssql-conn

Exemplo de uso

const { MSSQL } = require('mssql-conn')

let test = new MSSQL({
    "server": "127.0.0.1", //Ou localhost ou o IP do servidor
    "authentication": {
        "type": "default",
        "options": {
            "userName": "sa", //Usuário para logon
            "password": "sa" //Senha - não é seguro expor a senha como texto, use criptografia!
        }
    },
    "options": {
        "encrypt": false,
        "database": "db", //Nome do banco de dados
        "enableArithAbort": true,
        "appName": "default", //Nome da aplicação que vai conectar ao banco (SQL Server Profiler)
        "useColumnNames": true //O retorno das tabelas serão <objeto>.<nome da coluna>.value
    }
});

//Conectar ao banco de dados
//Este comando serve para fins de teste, ao usar select ou execute, a instância tentará se conectar automaticamente.

test.connect()
    .then(e => {
        //Conectado, uhull!
    })
    .catch(err => {
        //Deu erro
        console.log(err); //Mensagem de erro
    });

//Seleciona valores
let results = [];

test.select('SELECT * FROM TABELA', row => {  //Para cada linha encontrada, realizará um callback
    results.push(row);
}).then(() => {
    //Terminou o processo
}).cacth(err => {
    //Deu erro
    console.log(err); //Mensagem de erro
});

//Executa outros comandos, ou insere valores
test.execute("INSERT INTO TABELA ([Coluna 1], [Coluna 2]) VALUES ('OLÁ', 'MUNDO!')")
.then(() => {
    //Deu certo!
}).catch(err => {
    //Deu erro
    console.log(err);
});

QueryBuilder

O QueryBuilder é um auxiliar que simplifica as execuções de comandos SQL, permitindo usar arquivos .SQL ao invés de longos textos.

O QueryBuilder vai buscar arquivos SQL no caminho:

__dirname/SQL/<arquivo>.sql

Exemplo

//test = new MSSQL({...});

//Sem QueryBuilder
test.select('SELECT * FROM TABELA_FINANCEIRA WHERE [COLUNA] = 100');

//Com QueryBuilder
//QueryBuilder('<arquivo>', ...arg);
test.select(MSSQL.QueryBuilder('Financeira', '100')) //

Dentro do arquivo Financeira.sql, você encontraria isso:

SELECT * FROM TABELA_FINANCEIRA WHERE [COLUNA] = @VAR0

As variáveis seguem o padrão @VAR + o índice do argumento, iniciando em 0.

É possível alterar o nome da variável com o comando:

test.setVariable('FOO');

Agora, o QueryBuilder vai buscar nos arquivos variáveis com o padrão @FOO + o índice do argumento.

CLI

Use a linha de comando apenas para testar a conexão do ambiente Node com o Microsoft SQL Server:

mssqlt --userName="<usuário>" --password="<senha>" --database="<banco de dados>" --server="<IP ou local do servidor>"

Contribuições

Toda ajuda é bem-vinda!

Licença

MIT