Giter VIP home page Giter VIP logo

node-teradata's Introduction

node-teradata

Simple node-jdbc wrapper for teradata with promisified functions

NOTE: I do not claim ownership of, and will not support the teradata jdbc drivers. This package is in no way endorsed by teradata

A simple module to make working with teradata connections in node easier. Most of the work is done by the awesome node-jdbc module. I have simply provided a wrapper to save some time. It allows you to run queries against a teradata database. This wrapper returns bluebird promises to avoid nested callbacks. This module mostly follows the node-jdbc syntax for executing queries.

Setup

Add teradata jars to your Project:

  1. Download Drivers
  2. Create a directory named "jars" at the root of your project
  3. Extract downloaded drivers
  4. Copy "tdgssconfig.jar" and "terajdbc4.jar" into the newly created jars directory

** Alternatively you can make use of the teradataJarPath option and store your jars wherever you like

Install module

npm install teradata

NOTE: on OSX 10.10 with java 8.60 I had to set the CXX environment variable:

export CXX=gcc

then:

npm rebuild

Include module:

var Teradata = require("teradata");

Connect:

Teradata.connect('[url]' ,'[user]', '[password]')
    .then(function () {    
        // you are now connected
     });

You can also specify some options when connecting:

var options = {
    verbose: true,
    teradataJarPath: "[path-to-teradata-jdbc-drivers-directory]"
};
Teradata.connect('[url]' ,'[user]', '[password]')
    .then(function () {    
        // you are now connected
     });

verbose: turns on logging within the teradata package. can be useful for debugging

teradataJarPath: Allows you to store your downloaded Teradata JDBC jars somewhere other than the root of your project directory

Disconnect:

Teradata.disconnect()
    .then(function () {    
        // you are now disconnected
     });

Example Insert

Make sure to change the url, username, password, and insert query. Call .executeUpdate(query) for updates and inserts

    var Teradata = require("teradata");
        
    Teradata.connect('[url]' ,'[user]', '[password]')
        .then(function () {       
            return Teradata.executeUpdate("[insert query]");
        })
        .then(function (update count) {
            console.log("Updated %d records", updateCount);
            return Teradata.disconnect();
        });        

Example Select

Make sure to change the url, username, password, and select query. You can also optionally set a limit by changing [limit]

     var Teradata = require("teradata");
         
     Teradata.connect('[url]' ,'[user]', '[password]')
         .then(function () {       
             return Teradata.executeQuery("[select query]", [limit]);
         })
         .then(function (update count) {
             console.log("Updated %d records", updateCount);
             return Teradata.disconnect();
        });  

Dependencies

node-jdbc

bluebird

chalksay

Teradata jdbc driver

Contribute

Pull requests are welcome and will probably result in quicker changes than issues. Issues are of course welcome, and I will respond ASAP.

License

Module specific code licensed under MIT See Dependencies for included module licenses See Teradata site for JDBC driver

node-teradata's People

Contributors

gantrim avatar terkiterje avatar ubershmekel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.