Skip to content

is there a way to have redundancy on the connection? #35

@shimondoodkin

Description

@shimondoodkin

i want to have two Vertica nodes and i want to shutdown the 1st node and it will keep running ok on the second node.

like in mongodb i can give array of hosts as input to connection?

a module i use. all i need to do is a lot of inserts. i don't want to lose any insert.

// verticadb.js:

var Vertica = require('vertica');
vertica = Vertica.connect({host: '127.0.0.1', user: "user", password: 'password'}, function(err) {  if(err)throw err; });

/*
vertica.querycols=function(query, cb)
{
 var err=null;
 var result={cols:{}};
 var query =vertica.query("SELECT * FROM exchanges")
 //'fields' is emitted once.
 query.on('fields', function(fields) {result.fields=fields;for(var i=0,l=result.fields.length;i<l;i++) result.cols[result.fields[i].name]=[]; })
 // 'row' is emitted 0..* times, once for every row in the resultset.
 query.on('row', function(row) { for(var i=0,l=result.fields.length;i<l;i++) result.cols[result.fields[i].name].push(row[i]); })
 // 'end' is emitted once.
 query.on('end', function(status) { result.status=status; var cbb=cb;cb=function(){}; cbb(err,result) })
 // If 'error' is emitted, no more events will follow.
 // If no event handler is implemented, an exceptions gets thrown instead.
 query.on('error', function(err) { var cbb=cb;cb=function(){}; cbb(err,result) });
}
*/

vertica.query('SET SESSION AUTOCOMMIT TO ON', function(err, resultset) {   console.log( err,resultset?resultset.rows:'no result') });

verticaiprintq=false
verticainsert=function (t,x,cb,printq)
{
 var k=Object.keys(x)
 var ks=k.map(function(k){return '"'+k+'"'}).join(',');
 var vs=k.map(function(k){
 var v=x[k];
 if(typeof v=='string') return "'"+v+"'";
 else if(typeof v=='number') return (Math.round(v)==v?v:v.toFixed(9));//i have 9 in type someone else might need something else.
 else if(v===null)      return "null";
 else if(v===undefined)  return "null";
 else return 'E';
 }).join(',');
 var q="insert into "+t+"("+ks+") values("+vs+") ";
 if(printq||verticaiprintq)console.log('q=',q);
 vertica.query(q, cb?cb:function(err, resultset) {  if(err) console.log(x,q, err, resultset?resultset.rows:'no result'); });
}

///simple insert
//     var x={
//      id:1,
//      name:"shimon",
//     }
//     verticainsert('public.mynames',x);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions