-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
What is the fastest way to batch insert a large number of rows in SQLite using this gem?
Currently I use this:
db.execute('BEGIN TRANSACTION')
sql = 'INSERT INTO items (id, name) VALUES (?, ?)'
items.each_with_index { |name, id| db.execute(sql, [id, name]) }
db.execute('COMMIT')
The items come from a large files and need to be inserted in the SQLite database as fast as possible.
- Is there any better / optimized solution?
- For example I was considering to keep all the inserts in Ruby in an array and then use
execute_batch
, however I can't find a way to sanitize / interpolate the statements in this case. Is there a method likedb.sanitize(sql, [id, name])
?
Metadata
Metadata
Assignees
Labels
No labels