this is the insert code:
var id = flow.get('ID');
var value = flow.get('VALUE');
var attackvector = flow.get('ATTACKVECTOR');
var attackcomplexity = flow.get('ATTACKCOMPLEXITY');
var attackpriviliges = flow.get('ATTACKPRIVILIGES');
var interaction = flow.get('INTERACTION');
var confidentiality = flow.get('CONFIDENTIALITY');
var integrity = flow.get('INTEGRITY');
var availability = flow.get('AVAILABILITY');
var publisheddate = flow.get('PUBLISHEDDATE');
var type = flow.get('TYPE');
var newMsg = {
"topic": "INSERT INTO Database VALUES (" +
"'"+id+ "', " +
"'"+value + "', " +
"'"+attackvector + "', " +
"'"+attackcomplexity + "', " +
"'"+attackpriviliges + "'," +
"'"+interaction + "'," +
"'"+confidentiality + "'," +
"'"+integrity + "'," +
"'"+availability + "'," +
"'"+publisheddate + "'," +
"'"+type + "'"+
")"}
return newMsg;
This is the error message:
"Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: Database.ID"
this is the id function:
var r = /\W+/;
msg.payload = msg.payload.split(r);
var newMsg = { payload: msg.payload.length }
newMsg.payload = "";
var id = "";
for (var i = 0; i < msg.payload.length-1; i++)
{
if (msg.payload[i] == "ID" && msg.payload[i+1] == "CVE")
{
id += msg.payload[i+1] + "-" + msg.payload[i+2] + "-" + msg.payload[i+3] + "\n";
newMsg.payload += msg.payload[i+1] + "-" + msg.payload[i+2] + "-" + msg.payload[i+3] + "\n";
}
}
flow.set('ID',id);
return newMsg;
the result of the debug is one string with all the ID-s.
if i split, i get the rightdata (unique row for each ID):
but i cant insert to the table, because i don't understand how from a split node.
if i break the function like this:
var r = /\W+/;
msg.payload = msg.payload.split(r);
var newMsg = { payload: msg.payload.length }
newMsg.payload = "";
var id = "";
for (var i = 0; i < msg.payload.length-1; i++)
{
if (msg.payload[i] == "ID" && msg.payload[i+1] == "CVE")
{
id += msg.payload[i+1] + "-" + msg.payload[i+2] + "-" + msg.payload[i+3] + "\n";
newMsg.payload += msg.payload[i+1] + "-" + msg.payload[i+2] + "-" + msg.payload[i+3] + "\n";
break;
}
}
flow.set('ID',id);
return newMsg;
then i can put into the table:
but it is only one value, and i have a lot more.
this is the table:
CREATE TABLE Database(ID STRING PRIMARY KEY , VALUE STRING, ATTACK_VECTOR STRING, ATTACK_COMPLEXITY STRING, PRIVILIGES_REQUIRED STRING, USER_INTERACTION STRING, CONFIDENTIALITY_IMPACT STRING, INTEGRITY_IMPACT STRING, AVAILABILITY_IMPACT STRING, PUBLISHED_DATE STRING, TYPE STRING)
and the flow:
so can you help me please, how can i insert the data?