# Batch insert query using system.db?

**URL:** <https://forum.inductiveautomation.com/t/batch-insert-query-using-system-db/15693>\
**Category:** Ignition\
**Created:** [October 17, 2017, 6:42pm UTC](https://forum.inductiveautomation.com/t/batch-insert-query-using-system-db/15693 "2017-10-17T18:42:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 17, 2017, 6:42pm UTC](https://forum.inductiveautomation.com/t/batch-insert-query-using-system-db/15693/1 "2017-10-17T18:42:58Z")

</div>

In java you can execute batch query like :

```auto
import java.sql.Connection;
import java.sql.PreparedStatement;

//...

String sql = "insert into employee (name, city, phone) values (?, ?, ?)";
Connection connection = new getConnection();
PreparedStatement ps = connection.prepareStatement(sql);

for (Employee employee: employees) {

	ps.setString(1, employee.getName());
	ps.setString(2, employee.getCity());
	ps.setString(3, employee.getPhone());
	ps.addBatch();
}
ps.executeBatch();
ps.close();
connection.close();	
```

I don’t find any ignition system script function to achieve such batch command.  
I have lots of data to insert in Mysql DB, what is the most effective ignition script command for this ?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [October 17, 2017, 6:47pm UTC](https://forum.inductiveautomation.com/t/batch-insert-query-using-system-db/15693/2 "2017-10-17T18:47:32Z")

</div>

There is the [pa.db.insertRows](http://doc.perfectabstractions.com/modules/powerscripting/index.html#scripting-functions-db-insertrows) function from the[Power Scripting module](http://www.perfectabstractions.com/pa-power-scripting-module.html). It takes an Ignition dataset and efficiently inserts all the rows in the dataset into a database table. It is the easiest way in Ignition to efficiently insert many rows of data into a database table.
