I got stuck on the Cumulative Project ‘Codestrips’ with creating a new table in the sql.js file.
I wrote it like this:
db.run('DROP TABLE IF EXITS Strip', error => {
db.run(`
CREATE TABLE Strip (
id INTEGER PRIMARY KEY,
head TEXT NOT NULL,
body TEXT NOT NULL,
background TEXT NOT NULL,
bubble TEXT NOT NULL,
bubble_text TEXT NOT NULL DEFAULT '',
caption TEXT NOT NULL DEFAULT '')
`);
})
And, it would throw an error:
db.run('CREATE TABLE Strip (
^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
I eventually figured out that if I put in a backtick (`) rather than a single quote (’), then it did not throw an error and worked fine.
The thing is that I know I’ve used the single quote before in previous lessons and it worked:
db.run('CREATE TABLE Average (id INTEGER PRIMARY KEY, year INTEGER NOT NULL, temperature REAL NOT NULL)', logNodeError);
So, is this a rule that I should always use backticks?
Do I have to use them on db.get, db.all, etc.?
What is the protocol for using double quotes, single quotes and backticks in SQLite?
Thanks in advance,
Chip