# AutoSave Report to database?

**URL:** <https://forum.inductiveautomation.com/t/autosave-report-to-database/17841>\
**Category:** Ignition\
**Created:** [April 26, 2018, 7:01pm UTC](https://forum.inductiveautomation.com/t/autosave-report-to-database/17841 "2018-04-26T19:01:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmlhan](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@kmlhan](https://forum.inductiveautomation.com/u/kmlhan)\
**Post date:** [April 26, 2018, 7:01pm UTC](https://forum.inductiveautomation.com/t/autosave-report-to-database/17841/1 "2018-04-26T19:01:37Z")

</div>

I would like to autosave a report to a database to be read back later from various clients.

This code works great but its save as a PDF on the gateway.

```auto
d=system.tag.read("Kiln1/StartUp/K1 ChargeNum")
path="StartUp_K1_",d.value
load=system.tag.read("Kiln1/History/SaveStartupK1")
if load.value == 1 :
	settings = {"path":"D:\KilnReports\K1", "fileName":path, "format":"pdf"}
	system.report.executeAndDistribute(path="StartUpK1", project="Kiln_control", action="save", actionSettings=settings)
	system.tag.write("Kiln1/History/SaveStartupK1",0)

```

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [April 26, 2018, 8:12pm UTC](https://forum.inductiveautomation.com/t/autosave-report-to-database/17841/2 "2018-04-26T20:12:33Z")

</div>

I see 2 approaches to this. You could use [system.report.executeReport](https://docs.inductiveautomation.com/display/DOC79/system.report.executeReport) instead of system.report.executeAndDistribute to retrieve a byte array then store this to the database as a blob. However, this will take up a good chunk of space in the DB and potentially cause performance issues. A better approach is to use system.report.executeAndDistribute to save the file in a centralized location, then store the path to the file in your database.
