how to use online mysql database with node js
//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;Connected
Also in JavaScript:
- javascript backticks and if statements
- jquery show hide based on data attribute
- express case sensitive routing
- jsonarray find
- jquery get data-id
- dom is loaded
- jquery extract number from string
- javascript add class
- javascript hover event
- how to add multiple styles in javascript
- get params from route vuejs
- js method string remove extra spaces
- how to swap two images in javascript
- manage favicon with express app
- ngcc failed angular 9
- loop key in object
- hark javascript
- how to take create array using jquery
- javascript masking if input matches patter
- convert base64 to uint8array javascript
- express router middleware
- how get height elemnt with that margin in js
- settimeout in vuejs
- inertia.js