27 lines
850 B
Python
27 lines
850 B
Python
import paramiko
|
|
import sys
|
|
import io
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
HOST = "161.97.93.156"
|
|
USER = "carlos"
|
|
PASSWORD = "Innova1978+*?"
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(hostname=HOST, username=USER, password=PASSWORD, timeout=30)
|
|
|
|
sql = sys.argv[1] if len(sys.argv) > 1 else 'SHOW TABLES;'
|
|
cmd = f'docker exec -i appwrite-mariadb-sss6crntvrcs54qbhvhy5728 mysql -u sYoHWwl0DGvEyt3s -psn9YkZqoLV06CQxAy2qsKi36S7POVShT appwrite -e "{sql}"'
|
|
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
for line in stdout:
|
|
print(line.strip())
|
|
for line in stderr:
|
|
print("[ERR]:", line.strip())
|
|
|
|
client.close()
|