the following code updates a database on a remote server:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ssh_config['hostname'], username=ssh_config['user'], port=ssh_config['port'], key_filename=ssh_config['identityfile'][0])
stdin, stdout, stderr = client.exec_command(f'psql -U {dbuser} {db} < {targetfile}')
print(stdout.channel.recv_exit_status())
client.close()
This works fine, unless I remove the print statement – without it, the database is never updated. I guess that the command is not executed unless I request its exit status – why is that, and how can I force the command execution without referring to the exit code?
Thanks, Jan