Coder Social home page Coder Social logo

node-sqlnative's Introduction

sqlnative2.node - Native connection to SQL Server for Node.js

Installation

Download from GitHub and extract to your node-modules folder.

What is sqlnative2?

sqlnative2.node is a native (binary) library for Node.js that allows you to connect to SQL Server and execute SQL Statements (Stored Procedures, Queries, whatever can be done through a command object). It was developed due to the lack of working SQL clients for Node.js. The code is C++ and compiles in Visual Studios 2010 (professional required for 64 bit). The current library contains the 64 bit build of sqlnative2.node

Example:

console.log("Loading SQL Server driver");
var cs = require('../Debug/sqlnative2');

console.log("Connecting to DB Server");
var conn = new cs.SQLConnection('Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TEST;Data Source=localhost:1443');

console.log(new Array(40).join('-='));
console.log("Running a simple query against the server");
console.log(conn.query("EXEC [dbo].[TestProc]").length);

console.log(new Array(40).join('-='));
console.log("Now to break it by connecting to something that doesn't exist");
try{
  var conn2 = new cs.SQLConnection('Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=NOEXIST;Data Source=goBoom');
}catch(e){
  console.log("Got an error: ", e);
}

console.log(new Array(40).join('-='));
console.log("Try to brake it by sending a bad query");
try{
  conn.query("FRAZ BATZ NIMRO FREEBAR")
}catch(e){
  console.log("Got an error: ", e);
}

console.log(new Array(40).join('-='));
console.log("Try to brake it by selecting from a table that does not exist");
try{
  console.log(conn.query("SELECT * FROM this_table_does_not_exist"));
}catch(e){
  console.log("Got an error: ", e);
}

console.log(new Array(40).join('-='));
console.log("Finally re-run the query just to prove we still work");
console.log(conn.query("EXEC [dbo].[TestProc]"));

node-sqlnative's People

Contributors

jdarling avatar

Stargazers

Kevs(mt) avatar  avatar Michael Lam avatar Dan Wierenga avatar matthiasg avatar Oleg Efimov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.