I am looking for a ruby-specific solution to insert multiple rows using the INSERT..VALUES syntax
Currently I am generating individual insert statements, but this is very inefficient from a database perspective. I found some related questions, but not exactly what I'm looking for.
Example INSERT Statements (currently):
INSERT INTO qux SELECT 1,3,'foo';
INSERT INTO qux SELECT 4,11,'bar';
INSERT INTO qux SELECT 12,19,'baz';
INSERT multiple records using ruby on rails active record
The above question uses ActiveRecord to achieve what I am looking to do, but I am looking for a pure ruby approach.
how do I perform transactions with ruby mysql2
The above question uses transactions to achieve a result similar to my needs. However this is still not as efficient as using one INSERT VALUES statement.
Example data:
start,end,name
1,3,foo
4,11,bar
12,19,baz
INSERT VALUES Statement (desired):
INSERT INTO qux VALUES (1,3,'foo'),(4,11,'bar'),(12,19,'baz');
Any gem/codebase that already exists with this functionality?
UPDATE: I do not use and do not plan to use ActiveRecord in this particular project. I interact directly with the MySQL database and would love to know of any solution to my problem. One option may be building the functionality myself; however I don't want to re-invent the wheel here.