最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

postgresql - PostgreSQL16 : using pg_restore in a PowerShell script, but it only ever returns $null - Stack Overflow

programmeradmin1浏览0评论

I am automating a database reload as part of a test script. To my dismay, pg_restore.exe appears to only return $null. Even when deliberately mangling the file name, I get a $null back (although it prints a message to the screen). However a screen print doesn't do the script any good.

The line in the PowerShell script, which works, other than a complete lack of feedback...

$PGResult = &"C:\Program Files\PostgreSQL\16\bin\pg_restore.exe" --clean --dbname=postgresql://:@localhost:/<target_database> $DB_Filename

The $DB_Filename changes per run but the rest of the <> tags are a fixed part of the script.

Any idea how to get some kind of return code from pg_restore.exe so that the script knows if the database was successfully restored or not?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论