Skip to content

Error: SQLITE_BUSY: unable to close due to unfinalised statements #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
markc opened this issue Apr 3, 2011 · 3 comments
Closed

Error: SQLITE_BUSY: unable to close due to unfinalised statements #16

markc opened this issue Apr 3, 2011 · 3 comments

Comments

@markc
Copy link

markc commented Apr 3, 2011

FWIW using node from master (0.5pre) and gcc 4.5.2. I couldn't do the tests because the first test used 2Gb of swap and I had to kill it after 15 mins.

~ node db-test.js
1: Ipsum 0
2: Ipsum 1
3: Ipsum 2
4: Ipsum 3
5: Ipsum 4
6: Ipsum 5
7: Ipsum 6
8: Ipsum 7
9: Ipsum 8
10: Ipsum 9

events.js:45
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: SQLITE_BUSY: unable to close due to unfinalised statements
@kkaefer
Copy link
Contributor

kkaefer commented Apr 4, 2011

Can you please post the test files? Without these, it's pretty hard to determine why this error occurs. My guess is that one of the statements in your code isn't finalized. When you create statements with Database#prepare(), you have to call .finalize() on them; otherwise, sqlite will keep them around infinitely and won't allow closing the database.

@markc
Copy link
Author

markc commented Apr 5, 2011

Yes, of course, sorry. It was just the example at the top of README.md but with :memory: changed to an on disk file so I could check the results against my /usr/bin/sqlite3 v3.7.5.

var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('./test.sqlite');

db.serialize(function() {
  db.run("CREATE TABLE lorem (info TEXT)");

  var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
  for (var i = 0; i < 10; i++) {
      stmt.run("Ipsum " + i);
  }

  db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
      console.log(row.id + ": " + row.info);
  });
});

db.close();

@kkaefer
Copy link
Contributor

kkaefer commented Apr 5, 2011

Thank you, I fixed the error in the readme

@kkaefer kkaefer closed this as completed Apr 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants