This commit is contained in:
llopis15 2021-03-12 09:06:38 +01:00
parent 674145bb0a
commit 7bde341f21
1 changed files with 17 additions and 4 deletions

View File

@ -5,7 +5,20 @@ const pool = mariadb.createPool({
password: "llopis.19263",
connectionLimit: 5
});
pool.getConnection(){
.then(conn => {}
})
pool.getConnection()
.then(conn => {
conn.query("SELECT 1 as val")
.then(rows => { // rows: [ {val: 1}, meta: ... ]
return conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
})
.then(res => { // res: { affectedRows: 1, insertId: 1, warningStatus: 0 }
conn.release(); // release to pool
})
.catch(err => {
conn.release(); // release to pool
})
}).catch(err => {
//not connected
});