错误:SQLITE_ERROR:无此类列:未定义

时间:2018-10-05 21:52:57

标签: javascript node.js sqlite discord.js

我正在使用SQLite3 我有一列,但错误提示未创建“未定义”列。

const SQLite = require('sqlite3').verbose();
const db = new SQLite.Database('./database.sqlite');
db.serialize(function() {
db.run(`INSERT INTO users (id, name, soul, money, level, exp, items, weapon, 
armor, inbattle) VALUES(${message.author.id}, ${message.author.name}, 
"determination", 0, 1, 0, "DogFood", "Stick", "Bandage", "False");`);
})

events.js:183       投掷者//未处理的“错误”事件

错误:SQLITE_ERROR:没有这样的列:undefined

1 个答案:

答案 0 :(得分:0)

另一个错误的解决方法是在$ {message.author.username}中添加“”。 最终代码:

const SQLite = require('sqlite3').verbose();
const db = new SQLite.Database('./database.sqlite');
db.serialize(function() {
db.run(`INSERT INTO users (id, name, soul, money, level, exp, items, weapon, 
armor, inbattle) VALUES("${message.author.id}", "${message.author.username}", 
"determination", 0, 1, 0, "DogFood", "Stick", "Bandage", "False");`);
})