insert bulk values into table in sqlite

Solutions on MaxInterview for insert bulk values into table in sqlite by the best coders in the world

showing results for - "insert bulk values into table in sqlite"
Sophie
12 May 2017
1$data = array(
2   array(
3      'title' => 'My title' ,
4      'name' => 'My Name' ,
5      'date' => 'My date'
6   ),
7   array(
8      'title' => 'Another title' ,
9      'name' => 'Another Name' ,
10      'date' => 'Another date'
11   )
12);
13
14$this->db->insert_batch('mytable', $data); 
Ernest
17 Jan 2017
1# connect to db
2database = sqlite3.connect('database.db')
3cursor = database.cursor()
4
5# using INSERT INTO in bulk (where each line represents a new entry)
6cursor.execute('''INSERT INTO tablename (column1,column2) VALUES
7               (data1,data2),
8               (data3,data4),
9           	   (data5,data6),
10               (data7,data8)''')
11
12# disconnect from db :)
13database.commit()
14cursor.close()