我可以在nodejs上获取sqlite3插入物
我无法获得以下代码工作。当我使用SQLite二进制文件测试时,SQL语句可以工作,但是试图通过Nodejs SQLite3库运行它始终会导致以下错误。有人在使用图书馆之前可以帮我吗?
[Error: SQLITE_RANGE: column index out of range
Emitted 'error' event on Statement instance at:
] {
errno: 25,
code: 'SQLITE_RANGE'
}
db.serialize(() => {
db.run("CREATE TABLE IF NOT EXISTS account(id INTEGER PRIMARY KEY, firstname TEXT, lastname TEXT, password TEXT, email TEXT UNIQUE)");
db.run("INSERT INTO account(firstname, lastname, password, email) VALUES(@firstname, @lastname, @password, @email)", {firstname, lastname, password, email});
response.send('Successfully registered account');
response.end();
});
I can't get the following code to work. The SQL statement works when I test it with the sqlite binaries but trying to run it via the nodejs sqlite3 library always result in the following error. Can someone who have used the library before please help me?
[Error: SQLITE_RANGE: column index out of range
Emitted 'error' event on Statement instance at:
] {
errno: 25,
code: 'SQLITE_RANGE'
}
db.serialize(() => {
db.run("CREATE TABLE IF NOT EXISTS account(id INTEGER PRIMARY KEY, firstname TEXT, lastname TEXT, password TEXT, email TEXT UNIQUE)");
db.run("INSERT INTO account(firstname, lastname, password, email) VALUES(@firstname, @lastname, @password, @email)", {firstname, lastname, password, email});
response.send('Successfully registered account');
response.end();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您没有传递
insert
子句中的主键,因此您要么需要更新主键以自动提出,要么将其传递到insert
子句中。Since you are not passing the primary key in the
INSERT
clause, you either need to update the primary key to auto-increment, or pass it into theINSERT
clause.