Last active
August 29, 2023 01:11
-
-
Save bohdanszymanik/f268f6c1437e3afa02d3e228a9e3ef5f to your computer and use it in GitHub Desktop.
Typescript querying DB2
This file contains 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
// Assumes you've installed | |
// * the free IBM docker db2 edition | |
// * ibm_db for node: https://github.com/ibmdb/node-ibm_db | |
// Brings back multiple records as well. Found on the net can't remember where - oh, lots of js docs here: https://github.com/ibmdb/node-ibm_db/blob/master/APIDocumentation.md | |
import * as db2 from 'ibm_db'; | |
let cn: string = "DRIVER={DB2};DATABASE=testdb;HOSTNAME=127.0.0.1;UID=db2inst1;PWD=password;PORT=50000;PROTOCOL=TCPIP"; | |
db2.open(cn, function(err: any, conn: any){ | |
if (err) return console.log(err); | |
conn.query('select 1 from sysibm.sysdummy1', function (err: any, data: any) { | |
if (err) console.log(err); | |
else console.log(data); | |
conn.close(function () { | |
console.log('done'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment