Using Slick 2.0.2
When you have a case class that models your data, your Table class and your TableQuery object are defined, just read the file in Seq and add it to the TableQuery object using the ++ = function.
case class MyDataClass(id: String, date: String, msg: String)
class MyData(tag: Tag) extends Table[MyDataClass](tag,"mydatatableInDB") {
def id = column[String]("id")
def date = column[String]("date")
def msg = column[String]("msg")
def * = (id, date, msg) <> (MyDataClass.tupled)(MyDataClass.unapply)
}
val myDataTableQuery = TableQuery[MyData]
// read your data into a Seq[MyDataClass] (for example) and...
myDataTableQuery ++= listWithData
If you really need to do this with the package, you can group the elements grouped and repeat them by adding data to the table query at each iteration. Something like that:
// With your data already in a Seq
def insertIntoTableQuery(data: List[MyDataClass) = {
myDataTableQuery ++= data
}
// make groups of 1000 and iterate
listWithData.grouped(1000) foreach insertInToTableQuery
- , , :
Slick 2.0.2
. , , 350 000 , , . , , .