按照 Microsoft 提供的说明,我使用了以下代码。https://docs.microsoft.com/en-us/azure/azure-sql/database/connect-query-nodejs?tabs=windows
const { Connection, Request } = require("tedious");
// Create connection to database
const config = {
authentication: {
options: {
userName: "username", // update me
password: "password" // update me
},
type: "default"
},
server: "your_server.database.windows.net", // update me
options: {
database: "your_database", //update me
encrypt: true
}
};
const connection = new Connection(config);
// Attempt to connect and execute queries if connection goes through
connection.on("connect", err => {
if (err) {
console.error(err.message);
} else {
queryDatabase();
}
});
当我运行该应用程序时,没有任何反应,也没有任何记录。如何使用 Node.js 连接到 Azure SQL 数据库?