fix(restore): pass SQL via stdin to avoid newline escaping issues in psql_exec
This commit is contained in:
1 parent
15974b7977
commit
0283fa196a
1 file changed
+3
-4
@@ -101,12 +101,11 @@ def write_result(path, data):
|
||||
|
||||
def psql_exec(tcfg, dbname, sql):
|
||||
cmd = [
|
||||
'docker', 'exec', tcfg['db_container'],
|
||||
'docker', 'exec', '-i', tcfg['db_container'],
|
||||
'sh', '-ec',
|
||||
'export PGPASSWORD="${POSTGRES_PASSWORD:-}"; '
|
||||
f'psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At -c ' + json.dumps(sql),
|
||||
f'export PGPASSWORD="${{POSTGRES_PASSWORD:-}}"; exec psql -v ON_ERROR_STOP=1 -U "{tcfg["db_user"]}" -d "{dbname}" -At',
|
||||
]
|
||||
return subprocess.run(cmd, capture_output=True, text=True, timeout=60)
|
||||
return subprocess.run(cmd, input=sql, capture_output=True, text=True, timeout=60)
|
||||
|
||||
|
||||
def drop_db_if_exists(tcfg, dbname):
|
||||
|
||||
Reference in new issue
Block a user