You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Love your library, very easy to use and works pretty well.
I'm having an issue where if I call another function from the 'record' event that performs some sort of operation, like a mysql query, it only performs the operation for the first record. It won't perform the function for subsequent records until after the 'end' event.
For example:
parser.on('start',function(){console.log('start parsing');});parser.on('record',function(record){varsql='insert into table(field1,field2) values(?,?);';varinserts=[];inserts.push(record.field1);inserts.push(record.field2);console.log('inserting');varcmd=connection.format(sql,inserts);connection.query(cmd,function(err,res){if(err){console.log('MYSQL: '+sql+' \n'+err);return;}console.log('inserted successfully');});});parser.on('end',function(){console.log('end parsing');});
If I run the parser on a dataset of 100 records, I'll see 'start parsing', 'inserting' x 100, 'end parsing', then 'inserted successfully' x 100. In my real world application I'm reading datasets with several 100,000 rows, so this issue is much more apparent.
I'm not sure what could be causing the issue, perhaps reading the file as a stream would allow the db operation to flow through. Let me know if you would like any more specific details or troubleshooting, I'd be more than happy to help. Again, thanks for your work on this project, it's proven very useful to me.
The text was updated successfully, but these errors were encountered:
To clarify what I mean by "it only performs the operation for the first record". If you follow what I said my console.log() output was, between the time when 'inserting' is outputted and 'end parsing' is outputted, I only see 1 record in the database when I query it separately. After the 'end parsing' event, I then see more records being inserted. Like I said, this is more apparent with my real world dataset.
Love your library, very easy to use and works pretty well.
I'm having an issue where if I call another function from the 'record' event that performs some sort of operation, like a mysql query, it only performs the operation for the first record. It won't perform the function for subsequent records until after the 'end' event.
For example:
If I run the parser on a dataset of 100 records, I'll see 'start parsing', 'inserting' x 100, 'end parsing', then 'inserted successfully' x 100. In my real world application I'm reading datasets with several 100,000 rows, so this issue is much more apparent.
I'm not sure what could be causing the issue, perhaps reading the file as a stream would allow the db operation to flow through. Let me know if you would like any more specific details or troubleshooting, I'd be more than happy to help. Again, thanks for your work on this project, it's proven very useful to me.
The text was updated successfully, but these errors were encountered: