Can packages be updated in Sequel?

Is it possible to make many updates in one call with Sequel ?

For example, it might take several minutes on my server to create about 200 updates, but if I create one SQL query, it starts in seconds. I wonder if Sequel can be used to reinforce this SQL query, or even better, complete the whole operation with one shot.

+7
source share
3 answers

You can use Datset#import http://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html#method-i-import "Inserts multiple records into a linked table. This method can be used to efficiently insert a large number of records into a table in one query, if the database supports it. Inserts are automatically wrapped in a transaction. "

here is an example of how to use it:

 DB = Sequel.connect(...) DB[:movies].import([:id, :director, :title, :year], [[1, "Orson Welles", "Citizen Kane", 1941],[2, "Robert Wiene", "Cabinet of Dr. Caligari, The", 1920]]) 
+5
source

The solution I came across includes the update_sql method. Instead of executing the operation itself, it outputs raw SQL queries. To package multiple updates, simply attach them; in between, call the run method with the resulting string, and you are all set up.

The batch processing solution is faster than several updates.

+3
source
-one
source

All Articles