# Exporting SQL Database data to Excel?

**URL:** <https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206>\
**Category:** Ignition\
**Created:** [September 19, 2024, 8:25pm UTC](https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206 "2024-09-19T20:25:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [September 19, 2024, 8:25pm UTC](https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206/1 "2024-09-19T20:25:28Z")

</div>

Is there a way to export data from a SQL database without creating a report?

I know how to create a report and populate with data from my SQL database and once the report is generated you can export to excel and this works great. But I have an odd project where I don't really have a need to create the report but I would like to just export specific data from the database.

Any suggestion will be helpful.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 19, 2024, 8:27pm UTC](https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206/2 "2024-09-19T20:27:03Z")

</div>

`system.db.runQuery` + `system.dataset.toExcel`?

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [September 19, 2024, 8:33pm UTC](https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206/3 "2024-09-19T20:33:19Z")

</div>

Thanks Kevin, so does that actually create a dataset and then exports that to excel? Could you possibly provide a usage example?

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [September 19, 2024, 9:06pm UTC](https://forum.inductiveautomation.com/t/exporting-sql-database-data-to-excel/96206/4 "2024-09-19T21:06:56Z")

</div>

This is an example for a perspective button to download a dataset from my meter data:

```python
def runAction(self, event):
	params = {'start': self.getSibling("StartDate").props.value, 'end': self.getSibling("EndDate").props.value}
	results = system.db.runNamedQuery(system.project.getProjectName(),"MeterData", params)
	spreadsheet = system.dataset.toExcel(True,[results])
	system.perspective.download("Meter_Data_Raw.xlsx", spreadsheet)

```
