Answers for "npm install mysql"

SQL
1

npm install mysql2

npm install --save mysql2
Posted by: Guest on March-22-2021
4

how to manage a db connection in javascript

//put these lines in a seperate file
const mysql = require('mysql2');

const connection = mysql.createPool({
    host: "localhost",
    user: "",
    password: "",
    database: ""
    // here you can set connection limits and so on
});

module.exports = connection;

//put these on destination page
const connection = require('../util/connection');

async function getAll() {
    const sql = "SELECT * FROM tableName";
    const [rows] = await connection.promise().query(sql);
    return rows;
} 
exports.getAll = getAll;
Posted by: Guest on May-09-2020
1

npm mysql

npm i mysql2
Posted by: Guest on August-23-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language