This project is no longer maintained and has been archived. No further issues, PRs, or updates will be made.
Teradata for Node.js
- Asynchronous
- Read/Write
- Prepared Statements
- Connection Pool
- Keep Alive
npm install node-teradata
node-teradata uses JDBC to communicate with Teradata:
- Download and install JDK 8 (1.8.0 u112)
- Make sure Java is included in your system path
Other versions of the JDK may work, but they have not been tested
A JDBC driver is provided by Teradata for communicating with their databases via Java:
- Download the Teradata JDBC Driver (15.10.00.33)
- Create a "jars" folder in the root of your app
- Extract the archive's contents into the folder:
- tdgssconfig.jar
- terajdbc4.jar
Other versions of the Teradata JDBC Driver may work, but they have not been tested
Include module
var Teradata = require('node-teradata');
Create an instance
var teradata = new Teradata(config);
Example Config
var config = {
url: 'jdbc:teradata://myserver',
username: 'MyUsername',
password: 'MyPassword',
driver: './jars/',
minPoolSize: 1,
maxPoolSize: 100,
keepalive: {
interval: 60000,
query: 'SELECT 1',
enabled: true
},
jvmOptions: ['-Xrs']
};
var id = 7;
var sql = 'SELECT * FROM MyDatabase.MyTable WHERE Id = ' + id;
return teradata.read(sql)
.then(function(response) {
console.log(response);
});
var id = 7;
var sql = 'DELETE FROM MyDatabase.MyTable WHERE Id = ' + id;
return teradata.write(sql)
.then(function(count) {
console.log(count);
});
var id = 7;
var sql = 'SELECT * FROM MyDatabase.MyTable WHERE Id = ?';
return teradata.readPreparedStatement(sql, [
teradata.createPreparedStatementParam(1, 'Int', Number(id))
])
.then(function(response) {
console.log(response);
});
var id = 7;
var sql = 'SELECT * FROM MyDatabase.MyTable WHERE Id = :id';
return teradata.readPreparedStatement(sql, [
teradata.createPreparedStatementParam('id', 'Int', Number(id))
])
.then(function(response) {
console.log(response);
});
var id = 7;
var username = 'Foo';
var sql = 'UPDATE MyDatabase.MyTable SET Username = ? WHERE Id = ?';
return teradata.writePreparedStatement(sql, [
teradata.createPreparedStatementParam(1, 'String', username),
teradata.createPreparedStatementParam(2, 'Int', Number(id))
])
.then(function(count) {
console.log(count);
});
var id = 7;
var username = 'Foo';
var sql = 'UPDATE MyDatabase.MyTable SET Username = :username WHERE Id = :id';
return teradata.writePreparedStatement(sql, [
teradata.createPreparedStatementParam('id', 'Int', Number(id)),
teradata.createPreparedStatementParam('username', 'String', username)
])
.then(function(count) {
console.log(count);
});
See the docs for more information