import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('8.137.181.63', port=22, username='root', password='liyanxia@6688', timeout=10) stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"SELECT price_type, count(*) FROM fa_service GROUP BY price_type;\"") print("Remote DB before:", stdout.read().decode('utf-8')) stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"UPDATE fa_service SET price_type = 'fixed' WHERE price_type != 'fixed';\"") print("Remote update err:", stderr.read().decode('utf-8')) stdin, stdout, stderr = ssh.exec_command("mysql -uyjyf -pyjyf yjyf -e \"SELECT price_type, count(*) FROM fa_service GROUP BY price_type;\"") print("Remote DB after:", stdout.read().decode('utf-8')) ssh.close()