config.read(ini_file)
self.host = config[db]['host']
self.port = 3306
self.user = config[db]['user']
self.passwd = config[db]['passwd']
self.db = config[db]['db']
self.charset = config[db]['charset']
def get_conn(self):
try:
conn = pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.passwd, database=self.db, charset=self.charset)
return conn
except Exception as e:
print('%s', e)
sys.exit()
python连接数据库老是报错%s __init__() got an unexpected keyword argument 'password' 请教各位大神 是哪写的不对啊 还是说mysql不太支持python3呢
password 换成 passwd
conn = pymysql.connect(host=self.host, port=self.port, user=self.user, passwd=self.passwd, database=self.db, charset=self.charset)
初学,get