How to use ibm_db - 10 common examples

To help you get started, we’ve selected a few ibm_db examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM-Cloud / slack-chatbot-database-watson / eventFetch.js View on Github external
function fetchEventByShortname(dsn, eventname) {
 try {
    var conn=ibmdb.openSync(dsn);
    // Search for exact match only, could be extended with lIKE
    var data=conn.querySync("select shortname, location, begindate, enddate, contact from events where shortname=? fetch first 10 rows only", eventname);
    conn.closeSync();
    var resString="Date:\n";
    for (var i=0;i
github IBM-Cloud / slack-chatbot-database-watson / eventFetchDate.js View on Github external
function fetchEventByDates(dsn, eventdates) {
 try {
    var conn=ibmdb.openSync(dsn);
    // Base data is timestamp
    var data=conn.querySync("select shortname, location, begindate, enddate, contact from events where begindate between ? and ?", eventdates);
    conn.closeSync();
    var resString="Data: \n";
    for (var i=0;i
github IBM-Cloud / github-traffic-stats / slack / postWeeklyStats.js View on Github external
sum(clonecount) as clonecount, sum(cuniques) as cuniques
                  from v_repostats r, v_adminuserrepos v
                  where r.rid=v.rid
                  and tdate between this_week(current date - 7 days)+1 and (this_week(current date))
                  and v.email=?
                  group by r.rid, orgname, reponame
                  order by vuniques desc
                  fetch first 25 rows only`;
  const repoCountSql=`select count(rid) as repocount
                      from v_adminuserrepos
                      where email=?`;
 
  
try {
  // connect to database
  var conn=ibmdb.openSync(dsn);
   
  // retrieve weekly stats
  var data=conn.querySync(weeklySql,[emailid]);
  // retrieve repository count
  var repoCount=conn.querySync(repoCountSql,[emailid]);
  // close the connection
  conn.closeSync();

  // Compose the strings for the message and attachment
  //
  // We need the work week string for the previous week
  var workweek=moment().subtract(7, 'days').format("YYYY-WW");

  // the repository count
  var resString="*Total repositories*: "+repoCount[0]['REPOCOUNT'];
      resString+="\nSee more at INSERT YOUR URI here";
github IBM-Cloud / slack-chatbot-database-watson / eventInsert.js View on Github external
function insertEvent(dsn, eventValues) {
 try {
    var conn=ibmdb.openSync(dsn);
    // The timestamp value is derived from date and time values passed in
    var data=conn.querySync("insert into events(shortname, location, begindate, enddate, contact) values(?,?,timestamp_format(?||' '||?,'YYYY-MM-DD HH24:MI:SS'),timestamp_format(?||' '||?,'YYYY-MM-DD HH24:MI:SS'),?)", eventValues);
    conn.closeSync();
    return {result : data};
 } catch (e) {
     return { dberror : e }
 }
}
github SaifRehman / ICP-Airways / backend-test / app.js View on Github external
var ibmdb = require('ibm_db');

ibmdb.open("DATABASE=SAMPLE;HOSTNAME=localhost;UID=db2inst1;PWD=db2inst1-pwd;PORT=50000;PROTOCOL=TCPIP", function (err,conn) {
  if (err) return console.log(err);
  
  conn.query('select * from DB2INST1.VSTAFAC2', function (err, data) {
    if (err) console.log(err);
    else console.log(data);

    conn.close(function () {
      console.log('done');
    });
  });
});
github SaifRehman / ICP-Airways / icp-backend / signup-microservice / dist / App.js View on Github external
router.post('/createUser', function (req, res, next) {
            ibmdb.open(_this.connectionString, function (err, conn) {
                conn.prepare("insert into SAMPLE.UserData (LastName, FirstName, Location, Email, Password, Age) VALUES (?, ?, ?, ?, ?, ?)", function (err, stmt) {
                    if (err) {
                        console.log(err);
                        return conn.closeSync();
                    }
                    console.log(req.body.lastName);
                    stmt.execute([req.body.lastName, req.body.firstName, req.body.location, req.body.email, passwordhash.generate(req.body.password), req.body.age], function (err, result) {
                        if (err)
                            console.log(err);
                        else {
                            res.json({
                                message: "sucessful"
                            });
                            result.closeSync();
                        }
                        conn.close(function (err) { });
github SaifRehman / ICP-Airways / icp-backend / listing-schedule / dist / App.js View on Github external
router.get('/listFlightsByID/:id', (req, res, next) => {
            ibmdb.open(this.connectionString, function (err, conn) {
                conn.prepare('SELECT * FROM SAMPLE.FlightsData WHERE ID=?', function (err, stmt) {
                    if (err) {
                        console.log('errorr', err);
                    }
                    stmt.execute([req.params.id], function (err, result) {
                        result.fetch(function (err, data) {
                            if (err) {
                                console.error(err);
                                res.status(401).json({ message: "Server error" });
                                result.closeSync();
                            }
                            else {
                                if (data) {
                                    res.json({
                                        data,
                                        message: true
github SaifRehman / ICP-Airways / icp-backend / booking-microservice / dist / App.js View on Github external
router.post('/book', this.ensureToken, (req, res, next) => {
            ibmdb.open(this.connectionString, function (err, conn) {
                conn.prepare("insert into SAMPLE.Booking (TS, Checkin, UserID, FlightID) VALUES (CURRENT TIMESTAMP, '0', ?, ?)", function (err, stmt) {
                    if (err) {
                        console.log(err);
                        return conn.closeSync();
                    }
                    console.log(req.body.lastName);
                    stmt.execute([req.body.UserID, req.body.FlightID], function (err, result) {
                        if (err)
                            console.log(err);
                        else {
                            res.json({
                                message: "sucessful"
                            });
                            result.closeSync();
                        }
                        conn.close(function (err) { });
github SaifRehman / ICP-Airways / icp-backend / checkin-microservice / src / App.ts View on Github external
router.get('/checkin/:bookid/:userid', this.ensureToken, (req, res, next) => {
      ibmdb.open(this.connectionString, function (err, conn) {
        conn.prepare("UPDATE SAMPLE.Booking SET Checkin = '1' WHERE FlightID = ? AND UserID=? "
          , function (err, stmt) {
            if (err) {
              console.log('errorr', err);
              res.json({
                message: true
              });
            }
            stmt.execute([req.params.bookid, req.params.userid], function (err, result) {
              console.log(req.params.bookid, req.params.userid)
              if (err) {
                console.log('error', err)
                res.json({
                  message: true
                });
              }
github SaifRehman / ICP-Airways / icp-backend / checkin-microservice / dist / App.js View on Github external
router.get('/checkin/:bookid/:userid', this.ensureToken, (req, res, next) => {
            ibmdb.open(this.connectionString, function (err, conn) {
                conn.prepare("UPDATE SAMPLE.Booking SET Checkin = '1' WHERE FlightID = ? AND UserID=? ", function (err, stmt) {
                    if (err) {
                        console.log('errorr', err);
                        res.json({
                            message: true
                        });
                    }
                    stmt.execute([req.params.bookid, req.params.userid], function (err, result) {
                        console.log(req.params.bookid, req.params.userid);
                        if (err) {
                            console.log('error', err);
                            res.json({
                                message: true
                            });
                        }
                        else {

ibm_db

IBM DB2 and IBM Informix bindings for node

MIT
Latest version published 7 months ago

Package Health Score

66 / 100
Full package analysis

Popular ibm_db functions