Skip to content

Instantly share code, notes, and snippets.

@theduderog
Last active December 22, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theduderog/6426954 to your computer and use it in GitHub Desktop.
Save theduderog/6426954 to your computer and use it in GitHub Desktop.
Delayed destructor is node-odbc eventually causes SQL_INVALID_HANDLE to always be returned
var odbc = require('odbc'),
util = require('util'),
count = 0;
var getSchema = function () {
var db = new odbc.Database();
console.log(util.format('Count %s, time %s', count, new Date()));
console.log(db);
db.open("DSN=RetailSQLiteDSN", function(err) {
if (err) {
console.error("connection error: ", err.message);
db.close(function(){});
return;
}
db.describe({database: 'main', schema: 'RETAIL', table: 'PURCHASES'}, function (err, rows) {
if (err) {
console.error("describe error: ", err.message);
db.close(function(){});
return;
}
// console.log(rows);
db.close(function() {
console.log("Connection Closed");
db = null;
count += 1;
if (count < 100) {
setImmediate(getSchema);
}
});
});
});
};
getSchema();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment