[错误:SQLITE_ERROR:表格sheets没有名为sheet的列]

huangapple 未分类评论43阅读模式
英文:

[Error: SQLITE_ERROR: table sheets has no column named sheet]

问题

以下是翻译好的内容:

我向数据库中添加了一个新列,但似乎没有添加正确。我得到了以下错误。

这是我添加数据库的地方:

const sheets_db = new sqlite3.Database(__dirname + '/sheet.db',
    function(err){
        if(!err){
            sheets_db.run(`
                CREATE TABLE IF NOT EXISTS sheets(
                useremail TEXT,
                sheetname TEXT UNIQUE,
                sheet TEXT,
                status TEXT
                )
            `);
            console.log('opened sheet.db');
        }else{
            console.log('COULD NOT OPEN SHEET.DB', err)
        }
    }
);

这是我如何使用它:

sheets_db.run(`INSERT OR REPLACE INTO sheets (useremail,sheetname,sheet) VALUES(?,?,?)`,
    ["tim@mun.ca",name,strValues],
    function(err){
        if(!err){
            res.send({ok:true}); // 转换为 JSON
        }
        else{
            console.log("FAILED TO UPDATE: ",err);
            res.send({ok:false}); // 转换为 JSON
        }
    });

这是我得到的错误:

FAILED TO UPDATE:  [Error: SQLITE_ERROR: table sheets has no column named sheet] {
  errno: 1,
  code: 'SQLITE_ERROR'
}
英文:

I added a new column to my Database, but seems like it has not been
added correctly. I am getting the following errors.

This is where I am adding the database

const sheets_db = new sqlite3.Database(__dirname + '/sheet.db',
    function(err){
        if(!err){
            sheets_db.run(`
                CREATE TABLE IF NOT EXISTS sheets(
                useremail TEXT,
                sheetname TEXT UNIQUE,
                sheet TEXT,
                status TEXT
                )
            `);
            console.log('opened sheet.db');
        }else{
            console.log('COULD NOT OPEN SHEET.DB', err)
        }
    }

);

This is how i am using it

sheets_db.run(`INSERT OR REPLACE INTO sheets (useremail,sheetname,sheet) VALUES(?,?,?)`,
    ["tim@mun.ca",name,strValues],
    function(err){
        if(!err){
            res.send({ok:true}); //converts to JSON
        }
        else{
            console.log("FAILED TO UPDATE: ",err);
            res.send({ok:false}); //Converts to JSON
        }
    });

});

This is the error I am getting:

FAILED TO UPDATE:  [Error: SQLITE_ERROR: table sheets has no column named sheet] {
  errno: 1,
  code: 'SQLITE_ERROR'
}`enter code here`

huangapple
  • 本文由 发表于 2020年4月5日 08:59:45
  • 转载请务必保留本文链接:https://java.coder-hub.com/61036778.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定