ifbamoq
ifbamoq

Reputation: 437

Error: SQLITE_ERROR: no such column: undefined

I'm using SQLite3 I have a columns but the error says that column "undefined" is not created.

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 throw er; // Unhandled 'error' event

Error: SQLITE_ERROR: no such column: undefined

Upvotes: 1

Views: 11252

Answers (1)

ifbamoq
ifbamoq

Reputation: 437

The fix of another error was adding the "" to ${message.author.username}. Final code:

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");`);
})

Upvotes: 2

Related Questions