我在mysql数据库中有大约24k的行。现在使用nodejs我想查询然后将它存储在json文件中。
var fs = require('fs');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : '10.1.1.2',
user : 'xxx',
password : 'xxx',
database : 'xxx'
});
connection.connect();
var json = '';
var query = 'SELECT * FROM st_training GROUP BY EndDate ORDER BY StartDate DESC';
var query2 = 'SELECT * FROM st_training WHERE EmployeeID=901 GROUP BY EndDate ORDER BY StartDate DESC';
connection.query(query, function(err, results) {
if (err) { throw err;
}
else {
jsonV = JSON.stringify(results);
console.log(jsonV);
fs.writeFile('table.json', JSON.stringify(results), function (err) {
if (err) throw err;
console.log('Saved!');
});
}
connection.end();
});
我只能验证从console.log(jsonV)输出或table.json文件中保存的部分大约600行。 这可能会出错?它是否存在JSON.stringify的最大限制?