I'm getting a syntax error running sqlite3 in my node project. If it matters, I'm running it in a Cloud9 workstation. My code's pretty simple, I think.
var fs = require('fs');
var fileGens = 'generators.db';
var existsGens = fs.existsSync(fileGens);
if(!existsGens) {
console.log("Creating DB file 'generators'...");
fs.openSync(fileGens, 'w');
}
var sqlite3 = require('sqlite3').verbose();
var dbGens = new sqlite3.Database(fileGens);
dbGens.serialize(function() {
if(!existsGens) {
console.log('Creating db...');
}
dbGens.run("CREATE TABLE TerrainFrequencies (Primary TEXT, Secondary TEXT, Tertiary TEXT, WildCards TEXT)");
dbGens.run("INSERT INTO TerrainFrequencies VALUES (?, ?, ?, ?)", 'Water', 'Hills', 'Forest', 'Mountains,Desert');
console.log('About to select *');
dbGens.all("SELECT * FROM TerrainFrequencies", function(err, row) {
console.log('Selected...');
console.log(row);
});
});
dbGens.close();
I run it using node index.js, and my error...
Creating DB file 'generators'...
Creating db...
About to select *
events.js:141
throw er; // Unhandled 'error' event
^
Error: SQLITE_ERROR: near "Primary": syntax error
at Error (native)
Thanks in advance!