# Once report is created using data from database how to delete that database table using python script

**URL:** <https://forum.inductiveautomation.com/t/once-report-is-created-using-data-from-database-how-to-delete-that-database-table-using-python-script/28444>\
**Category:** Ignition\
**Tags:** database\
**Created:** [September 20, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/once-report-is-created-using-data-from-database-how-to-delete-that-database-table-using-python-script/28444 "2019-09-20T20:10:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spatel](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@spatel](https://forum.inductiveautomation.com/u/spatel)\
**Post date:** [September 20, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/once-report-is-created-using-data-from-database-how-to-delete-that-database-table-using-python-script/28444/1 "2019-09-20T20:10:26Z")

</div>

Hello,

Using script I am inserting data in database table and after that, I am using that data from the database to generate the report. But once the report is created and printed I wanna delete that chunk of data from the database which was used to create the report. How can I achieve this using python script?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [September 20, 2019, 10:49pm UTC](https://forum.inductiveautomation.com/t/once-report-is-created-using-data-from-database-how-to-delete-that-database-table-using-python-script/28444/2 "2019-09-20T22:49:30Z")

</div>

Are you wondering how to structure a DELETE statement in SQL or how to run that statement in a python script?

[runQuery()](https://docs.inductiveautomation.com/display/DOC80/system.db.runQuery) can be used to delete data. If you’re looking for how to structure the query itself, the form is  
`DELETE FROM <table_name> WHERE <condition> ;`  
Make sure you have legacy db access turned on to do this.
