admin管理员组文章数量:1352184
I am trying to create a new table using node.js and better-sqlite3. When I execute the file, it returns the following error:
ReferenceError: createtable is not defined at Object.<anonymous> (...my file's path...)
How can I solve it? Here's my code:
const express = require('express');
var createError = require('http-errors');
const app = express();
const port = 3000;
const sqlitedb = require('better-sqlite3');
const createTable = "CREATE TABLE IF NOT EXISTS users('name' varchar, 'surname' varchar, 'date_of_birth' DATE DEFAULT, 'email' varchar, 'username' varchar PRIMARY KEY, 'password' varchar );"
const dbusers = './databaseUsers.sqlite3';
let db = new sqlitedb(dbusers , sqlitedb.OPEN_READWRITE, (err) => {
if (err) {
console.error(err.message);
}
verbose: console.log}
);
db.exec(createtable);
Thank you in advance ;)
I am trying to create a new table using node.js and better-sqlite3. When I execute the file, it returns the following error:
ReferenceError: createtable is not defined at Object.<anonymous> (...my file's path...)
How can I solve it? Here's my code:
const express = require('express');
var createError = require('http-errors');
const app = express();
const port = 3000;
const sqlitedb = require('better-sqlite3');
const createTable = "CREATE TABLE IF NOT EXISTS users('name' varchar, 'surname' varchar, 'date_of_birth' DATE DEFAULT, 'email' varchar, 'username' varchar PRIMARY KEY, 'password' varchar );"
const dbusers = './databaseUsers.sqlite3';
let db = new sqlitedb(dbusers , sqlitedb.OPEN_READWRITE, (err) => {
if (err) {
console.error(err.message);
}
verbose: console.log}
);
db.exec(createtable);
Thank you in advance ;)
Share Improve this question edited Aug 23, 2021 at 7:28 hellomynameisA asked May 17, 2020 at 19:13 hellomynameisAhellomynameisA 6344 gold badges12 silver badges35 bronze badges 2-
1
Typo in
verbose: console.log}
– Roko C. Buljan Commented Mar 9, 2022 at 11:01 - Thanks @RokoC.Buljan, I upvoted your ment – hellomynameisA Commented Mar 10, 2022 at 11:14
1 Answer
Reset to default 7You have a typo in the variable declaration. The variable you declared is createTable instead of createtable (note the capitalized T). So it should be:
db.exec(createTable);
本文标签: javascriptCreate new table using bettersqlite3Stack Overflow
版权声明:本文标题:javascript - Create new table using better-sqlite3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743908750a2559994.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论