node-mariasql icon indicating copy to clipboard operation
node-mariasql copied to clipboard

Example code for executing 1000 queries in a single batch for a prepared statement

Open elgs opened this issue 8 years ago • 2 comments

I have an insert statement which looks something like this:

INSERT INTO mytable SET A=?, B=?;

Now I want to insert 1000 rows into mytable in a single connection. Can I do something like this?

prepareBatch(['a1', 'b1']); prepareBatch(['a2', 'b2']); prepareBatch(['a3', 'b3']); ... prepareBatch(['a1000', 'b1000']); executeBatch();

If this is possible, can you please show some example code? Thanks.

elgs avatar Mar 16 '17 10:03 elgs

Perhaps you can read readme from last example. Note: prepared function only available on that coonetion session

jimmyolo avatar Mar 16 '17 12:03 jimmyolo

I have read the readme thoroughly, and the last example seems to run only one query in a batch. Any more detailed example will be greatly appreciated.

elgs avatar Mar 16 '17 16:03 elgs