Can't open a data base on disk
I'm new with sqlite3 and have some dudes whit him. When I try open a sqlite file this error is triggered to me:
{ open: false,
filename: './datos_exportados(14-05-2015o).sqlite',
mode: 65542 }
And the file exists, somebody can help me? It is my code:
var sqlite3 = require('sqlite3').verbose(),
path = './datos_exportados(14-05-2015o).sqlite';
var sipac = new sqlite3.Database(path, 'OPEN_READONLY');
sipac.serialize(function(){
var dat_act = sipac.run("SELECT * FROM dat_actividades")
console.log(dat_act)
})
sipac.close()
Probably a bit late but...
That isn't an error. If you check the documentation db.run returns a copy of the database so that you can chain another method if needed. That means console.log(dat_act) is actually console.log(sipac) so you are printing the representation of the db object to the console.
db.run is meant for running queries which don't return any results e.g. insertions. You need to use either db.all or db.get or db.each and pass them a callback function to handle the results:
var sqlite3 = require('sqlite3').verbose(),
path = './datos_exportados(14-05-2015o).sqlite';
var sipac = new sqlite3.Database(path, 'OPEN_READONLY');
sipac.serialize(function(){
sipac.each("SELECT * FROM dat_actividades", function(err, row) {
if (err)
console.log(err)
else
console.log(row)
})
})
sipac.close()
Check out the api on the wiki if you haven't read it.
This is so helpful! I had the same problem. I read the wiki first but nothing stood out to me.
Closing as this appears to be resolved.