# Dumping postgre tables via Perspective?

**URL:** <https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 13, 2024, 5:09am UTC](https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286 "2024-05-13T05:09:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 13, 2024, 5:09am UTC](https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286/1 "2024-05-13T05:09:20Z")

</div>

How can I dump PostgreSQL tables (schema and/or data) via Perspective?

I have PgAdmin installed on the Ignition Gateway and presumed that I could use pg\_dump via `system.util.execute` to run this locally on the gateway via Perspective to dump to a local file to then read... but i've spent far too long trying to work it out. Trying to diagnose issues running things through `execute` is exhausting...

Currently I have:

```python
system.util.execute(['cmd', '/c'
	, r'"c:\Program Files\pgAdmin 4\v7\runtime\pg_dump.exe --schema-only -s -t cfg_machines postgresql://USER:PASSWORD@IP_ADDRESS:5432/DATABASE'
	, r'>> c:\logs\output.txt 2>%1'
])

```

But this doesn't work. The `r'>> c:\logs\output.txt 2>%1'` part should be writing all errors and output into the text file but the textfile is created and is blank. This runs fine within CMD locally on the gateway server. Obviously the all caps are real values.

This _does_ work:

```python
system.util.execute(['cmd', '/c'
	,'echo charlie'
	, r'> c:\logs\output.txt'
])

```

Ignition service is running under a specific user that has admin rights.

Am I overcomplicating this, how else can I do it? Or, how can I get this to work?  
PS. this is to assist setting up a gazillion local machine databases.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 13, 2024, 5:27am UTC](https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286/2 "2024-05-13T05:27:10Z")

</div>

I've resorted to creating a bat file and calling that for now 😕

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 13, 2024, 11:40am UTC](https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286/3 "2024-05-13T11:40:02Z")

</div>

I never use `system.util.execute`. It is fire-and-forget, with no feedback nor collection of the executable's output. Use java's `ProcessBuilder` and connect streams to the executable's output and error pipes.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 13, 2024, 2:05pm UTC](https://forum.inductiveautomation.com/t/dumping-postgre-tables-via-perspective/90286/4 "2024-05-13T14:05:16Z")

</div>

> [@pturmel](#):
>
> `ProcessBuilder`

Much nicer! Cheers, got it working now 🙂
