Welcome Guest, Not a member yet? Register   Sign In
Import csv long file into sqlite database takes too long
#4

(This post was last modified: 08-19-2016, 09:57 PM by PaulD.)

Not really, that is a different thing.

The transactions you are talking about there do something like an entire series of queries, inserts, updates and deletes, but if any of the queries within one transaction fails, they are all cancelled and none of them are implemented. Any changes made during that transaction are rolled back. Imagine a bank has to take some money out of one account and then add it to another, but the add fails, so the bank wants the entire transaction to roll back to the original state, so no money is lost anywhere.

Insert batch just writes the sql query for you but inserting lots of data all in one go in a single sql query. (I say 'just' but that is not to imply it is simple or unsophisticated). All the batch functions are pretty cool actually.

From the docs (http://www.codeigniter.com/user_guide/da...sert_batch)

PHP Code:
$data = array(
 
   array(
 
       'title' => 'My title',
 
       'name' => 'My Name',
 
       'date' => 'My date'
 
   ),
 
   array(
 
       'title' => 'Another title',
 
       'name' => 'Another Name',
 
       'date' => 'Another date'
 
   )
);

$this->db->insert_batch('mytable'$data);
// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'),  ('Another title', 'Another name', 'Another date') 

Best wishes,

Paul.
Reply


Messages In This Thread
RE: Import csv long file into sqlite database takes too long - by PaulD - 08-19-2016, 09:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB