Mariadb-Developer-Examples/Flights/src/db.js

24 wiersze
555 B
JavaScript
Czysty Zwykły widok Historia

2019-12-16 23:02:28 +00:00
var fs = require("fs")
var mariadb = require('mariadb');
2019-12-16 23:31:59 +00:00
// Configure the database connection
2019-12-16 23:02:28 +00:00
const pool = mariadb.createPool({
2019-12-16 23:31:59 +00:00
host: '<Hostname_Here>',
user:'<Username_Here>',
2019-12-16 23:02:28 +00:00
port: 5002,
2019-12-16 23:31:59 +00:00
password: "<Password_Here>",
2019-12-16 23:02:28 +00:00
database: 'flights',
connectionLimit: 5
});
module.exports={
getConnection: function(){
return new Promise(function(resolve,reject){
pool.getConnection().then(function(connection){
resolve(connection);
}).catch(function(error){
reject(error);
});
});
}
}