【问题标题】:Error: SQLITE_ERROR: no such column: undefined错误:SQLITE_ERROR:没有这样的列:未定义
【发布时间】:2019-03-11 10:31:33
【问题描述】:

我正在使用 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:没有这样的列:未定义

【问题讨论】:

    标签: javascript node.js sqlite discord.js


    【解决方案1】:

    另一个错误的修复是将“”添加到 ${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");`);
    })
    

    【讨论】:

    • 一年多之后,我意识到这样做是非常错误的。使用?将数据放入数据库。
    猜你喜欢
    • 2018-12-20
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    • 2021-12-29
    • 2020-10-17
    • 1970-01-01
    • 2021-08-02
    相关资源
    最近更新 更多