【发布时间】:2014-05-12 15:40:50
【问题描述】:
在 Linux 上运行时,如何从 node.js 连接到 SQL Server 或 SQL Azure。
我在 npm 上找到的驱动都需要 Windows + VS2005。有没有办法从 Linux 访问 SQL Server?
【问题讨论】:
标签: sql-server node.js azure azure-sql-database
在 Linux 上运行时,如何从 node.js 连接到 SQL Server 或 SQL Azure。
我在 npm 上找到的驱动都需要 Windows + VS2005。有没有办法从 Linux 访问 SQL Server?
【问题讨论】:
标签: sql-server node.js azure azure-sql-database
我找到了一个可行的解决方案,直接使用'tedious'。
var Connection = require('tedious').Connection;
var config = {
userName: 'myuser@servername',
password: 'mypassword',
server: 'servername.database.windows.net',
// If you're on Windows Azure, you will need this:
options: {
encrypt: true
}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
if(err)
console.log(err)
else
console.log('works!!!!!')
});
【讨论】: