var mysql = require(‘mysql‘; var connection = mysql.createConnection({ host: ‘‘, port: 3306, user: ‘root‘, password: ‘root‘, database: ‘testdb‘ }); connection.connect(function(err){ if(err) console.log(‘err‘); else{ // connection.query(‘select * from suers where sex=:sex‘, {sex:1}, ... connection.query(‘select * from users where sex=?‘, [1], function(err2, rows){ if(err2) console.log(‘query error‘); else { console.log(rows); connection.end(); } }); } });
时间: 2024-11-02 17:34:42