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:
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:
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.