import paramiko
import time
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('123.369.321.1', port=22, username='root', password='')
time.sleep(5)
def execute():
stdin, stdout, stderr = ssh.exec_command("mysql -uroot -e 'SELECT a.id as customer_id,a.external_id FROM billing.contracts a LEFT JOIN billing.contacts b ON a.contact_id = b.id WHERE a.status = 'active' AND b.reseller_id IS NOT NULL'")
execute()