Last active
December 22, 2015 05:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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