I'm trying to do a bulk insert with SQLite Swift. However, I'm not 100% sure if my code is correct.
The Swift code I've settled on (because it delivered the best performance timewise) is:
do {
   try DB.transaction { () -> Void in
     for index in 0...num_docs {
       table.insert(data <- "test", data_num <- index)
      } 
    } 
} catch _ {
 throw DataAccessError.Transaction_Error
}
EDIT ----
If I would use the following code in swift, inserting 10000 docs drops from +/- 12 secs to 0.8 secs. What sounds too good to be true.
  let docsTrans = DB.prepare("INSERT INTO TEST_DB (data, data_num) VALUES (?,?)")
    do {
       try DB.transaction(.Deferred) { () -> Void in
         for index in 0...num_docs {
           try docsTrans.run("test", index)
          } 
        }
     } catch _ {
            throw DataAccessError.Insert_Error
        }
