16 lines
474 B
Python
16 lines
474 B
Python
import subprocess
|
|
|
|
sql = "SELECT id, email, role, name FROM users WHERE role = 'ADMIN' ORDER BY id;\n"
|
|
|
|
proc = subprocess.Popen(
|
|
['ssh', 'root@76.13.55.81', 'docker exec -i postgres-staging psql -U metallkart -d erp_staging'],
|
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
)
|
|
out, err = proc.communicate(input=sql.encode('utf-8'))
|
|
|
|
with open('c:/Projects/metallkart-erp/tmp_q.txt', 'wb') as f:
|
|
f.write(out)
|
|
f.write(err)
|
|
|
|
print('done')
|