import os
import string
from fabric import Connection
import configparser
import socket
config = configparser.RawConfigParser(allow_no_value=True)
configFilePath = r'/root/config.ini'
config.read(configFilePath)
puser = config.get('Server', 'user')
#print (puser)
db_server = list(config.items('Database'))
#print (db_server)
def host_connect():
for key in db_server:
print (key[0])
conn = Connection(host="puser@{0}".format(key[0]))
conn.run('ps -ef | grep postgres')
I am trying to run this code and getting error as Traceback (most recent call last): File "psql_cleanlogs.py", line 6, in from fabric import Connection ImportError: cannot import name 'Connection'
The same procedure I have done in different codes and it ran fine but here is it is creating troubles. I am using python3 virtual env