chofoo / mssqlhelper Goto Github PK
View Code? Open in Web Editor NEWnodejs Microsoft SQL Server Helper nodejs的一个用于连接mssql数据库的工具类
Home Page: http://play175.github.com/mssqlhelper/
nodejs Microsoft SQL Server Helper nodejs的一个用于连接mssql数据库的工具类
Home Page: http://play175.github.com/mssqlhelper/
# nodejs Microsoft SQL Server Helper # nodejs的一个用于连接mssql数据库的工具类 ## Features 介绍 * 采用微软tds协议,不需要任何C/C++扩展,跨平台使用 * 执行sql语句,获得结果行 * 执行存储过程,获得输出参数以及结果行 ## TODO 待实现内容 * 将支持获得多个结果集(Table) * 将支持连接池 * 更多性能加强 ## Requirements 需要如下组件(已内置) * [tds](http://cretz.github.com/node-tds/)(已内置) ## Use 使用 $ git clone [email protected]:play175/mssqlhelper.git $ cd mssqlhelper $ node test.js ## Test 测试代码 var db = require('./index'); db.config({ host: '192.168.1.100' ,port: 1433 ,userName: 'sa' ,password: '123' ,database:'testdb' }); //test query sql 执行sql db.query( 'select @Param1 Param1,@Param2 Param2' ,{ Param1: { type : 'NVarChar', size: 7,value : 'myvalue' } ,Param2: { type : 'Int',value : 321 } } ,function(res){ if(res.err)throw new Error('database error:'+res.err.msg); var rows = res.tables[0].rows; for (var i = 0; i < rows.length; i++) { console.log(rows[i].getValue(0),rows[i].getValue('Param2')); } } ); //test excute sp 执行存储过程 db.exec( 'test_sp' ,{ Param1: {direction:'out', type : 'NVarChar', size: 50,value : 'my Param1 value' } ,Param2: { type : 'Int',value : 123 } ,Param3: {direction:'out', type : 'VarChar', size: 50,value : '789' } } ,function(res){ if(res.err)throw new Error('database error:'+res.err.msg); //get output paramater value console.log('output @Param1='+res.params.Param1.value); //get rows var rows = res.tables[0].rows; for (var i = 0; i < rows.length; i++) { var rp = ''; for(var j=0,len = rows[i].metadata.columns.length;j<len;j++){ var col = rows[i].metadata.columns[j]; rp += ' ' +(rows[i].getValue(j)); } console.log(rp); } } );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.