首先,我肯确定的是,数据库正常连接,有相应的数据表。而且写入正常。
mysql> select * from appoint where id=1; | ||||
---|---|---|---|---|
id | name | phone | weixin | message |
通过手动查询没有毛病。
以下是写入数据库的代码,前端也能正常调用,写入。
if (phone !== "" || weixin !== "") {
database.query(`INSERT INTO appoint (name,weixin,phone,message) VALUES ('${name}','${weixin}','${phone}','${message}')`,
(err, result) => {
if (err) { console.log(err.message); }
})
}
以下是读取代码,显示没有对应的数据表,我很无语。
database.query("SELECT * FROM appoint",(err,result) => {
if(err) {reject(ctx.response.body = `出错了${err.message}`)}
console.log(typeof result);
resolve(ctx.response.body = result);
})
})
Error: non-error thrown: "出错了ER_NO_SUCH_TABLE: Table 'anxin.APPOINT' doesn't exist"
at Object.onerror (/root/anxin/node_modules/koa/lib/context.js:119:31)
at onerror (/root/anxin/node_modules/koa/lib/application.js:165:32)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)`
1、有可能是MySQL设置了参数lower_case_table_names,这个值设置为大小写敏感
2、有可能是这个表和其所属的schema不匹配