Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
elgs opened this issue Mar 16, 2017 · 2 comments

Comments

@elgs
Copy link

elgs commented Mar 16, 2017

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.

@jimmyolo
Copy link

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

@elgs
Copy link
Author

elgs commented Mar 16, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants