Skip to content

Instantly share code, notes, and snippets.

@ryantanner
Created March 20, 2013 01:38
Show Gist options
  • Save ryantanner/5201667 to your computer and use it in GitHub Desktop.
Save ryantanner/5201667 to your computer and use it in GitHub Desktop.
Anorm batch insert demo
def saveList(list: List[Long]) = {
DB.withConnection { implicit connection =>
val insertQuery = SQL("insert into UserActions(action) values ({action})")
val batchInsert = (insertQuery.asBatch /: list)(
(sql, elem) => sql.addBatchParams(elem)
)
batchInsert.execute()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment