Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
htest('sqlite test shutdown', t => {
db.close()
.then(() => {
console.log('shut down sqlite')
t.ok(true, 'finished db.close')
t.end()
// And exit on next tick:
setImmediate(() => { process.exit(0) })
})
})
}
let hrQueryStart = 0
await db.open(':memory:')
await csvimport.importSqlite(testPath, ',', {noHeaderRow: false})
// await db.open('/Users/antony/data/testdb.sqlite')
const [es, ens] = process.hrtime(hrProcStart)
console.info('runQuery: import completed in %ds %dms', es, ens / 1e6)
// console.log('table import complete: ', md.tableName)
console.log('running query:\n', tq)
hrQueryStart = process.hrtime()
const rows = await db.all(tq)
const [qes, qens] = process.hrtime(hrQueryStart)
console.log('read rows from sqlite table.')
console.table(rows)
console.info('runQuery: evaluated query in %ds %dms', qes, qens / 1e6)
await db.close()
} catch (err) {
console.error('caught exception running query: ', err, err.stack)
}
}
.then(() => db.close())
.catch(err => console.error('error in runSqlite promise chain: ', err, err.stack))