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 🙏

© 2024 – Pkg Stats / Ryan Hefner

iver-mssql

v1.0.2

Published

提供一种用nodejs操作SQLServer的简单方式

Downloads

4

Readme

iver-mssql

用nodejs操作SQLServer数据库。一般用于处理数据导入或导出等日常事务,适合用nodejs作为工具语言的开发者。

Install

npm install --save iver-mssql

Method

  • Connect - promise方法 - 连接数据库,初始化打开数据库连接 Connect(conStr : string) : object 入参连接字符串,返回一个连接对象,关闭连接之前保存。
  • Query - promise方法 - 数据库查询 Query(sqlStr : string) : object[] 入参sql语句,返回查询结果-对象数组。
  • Transaction - promise方法 - 数据库操作 Transaction(sqlList : string[]) : bool or string[] 入参包含sql语句的字符串数组,成功返回TRUE,失败返回执行错误的sql语句,便于排查语法错误。
  • Close - 普通方法 - 关闭数据库连接 Close(con : object) : void 入参为Connect方法返回的对象。

Usage

const { Connect, Query, Transaction, Close } = require("mssql-help");
async function test() {
  //改成自己数据库的连接字符串
  const conStr = `mssql://yourUsername:yourPwd@ServerName/DataBaseName`;
  //初始化打开数据库连接
  const con = await Connect(conStr);

  //必须初始化执行Connect方法初始化,才能执行Query,Transaction等方法

  //数据库查询
  const sqlStr = `SELECT * FROM table_name`;
  const ArrList = await Query(sqlStr);

  //执行事务-更新删除等操作
  const sqlList = [
    "INSERT INTO table_name VALUES (value1,value2,value3,...)",
    "UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value",
    "DELETE FROM table_name WHERE some_column=some_value"
  ];
  //成功result返回true;执行失败result返回执行错误的SQL语句,可以将其写入文件,方便调试
  const reuslt = await Transaction(sqlList);
  //执行Query或者Transaction完成后,关闭数据库连接
  Close(con);
}