Answer the question
In order to leave comments, you need to log in
Why query error in MySQL?
Hello, I'm trying to master the MySQL + Node. For some reason, when executing this code:
const mysql = require('mysql');
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password'
});
connection.connect();
const person = 'Ginger Baker';
const query = connection.query("INSERT INTO ?? SET ?? = ?", ['artist', 'name', 'person'], (err, rows) => {
if (err) {
console.log('Ошибка запроса');
console.log(err);
} else {
console.log(rows);
};
});
connection.end();
Answer the question
In order to leave comments, you need to log in
No database selected:
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'my_db' <===============
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question