Python PEP8清理-访问类的受保护成员(上次执行)
我有下面的代码块,它捕获了几种不同的查询类型的警告,并将它们写入很多,如果它们失败/警告,就会向我发送一条谷歌聊天消息。我在Python PEP8清理-访问类的受保护成员(上次执行),python,pep8,Python,Pep8,我有下面的代码块,它捕获了几种不同的查询类型的警告,并将它们写入很多,如果它们失败/警告,就会向我发送一条谷歌聊天消息。我在str(游标上一次执行)上收到一个pep8错误: 访问类的受保护成员(上次执行) 我需要对此进行更改吗?它做了我想做的事情——将mysql的失败信息发送到日志中 db = MySQLdb.connect("localhost", "root", "1234", "search") cursor = db.cursor() try: with warnings.cat
str(游标上一次执行)
上收到一个pep8错误:
访问类的受保护成员(上次执行)
我需要对此进行更改吗?它做了我想做的事情——将mysql的失败信息发送到日志中
db = MySQLdb.connect("localhost", "root", "1234", "search")
cursor = db.cursor()
try:
with warnings.catch_warnings(record=True) as w:
if warn_type == 2:
cursor.execute(query_string, kargs['field_split'] + kargs['user'])
elif warn_type == 3:
cursor.execute(query_string, (
kargs['reportid'], kargs['timestamp'], kargs['reportid'], kargs['reportid'], kargs['timestamp']))
else:
cursor.execute(query_string, kargs['field_split'])
db.commit()
if w:
logger.warning('Mysql Warning : %s', w[-1])
logger.warning('Statement : %s', str(cursor._last_executed))
logger.warning(kargs['field_split'])
# noinspection PyUnresolvedReferences
string_google = 'Warning - ' + str(w[-1].message) + ' - ' + str(cursor._last_executed)
googlechat(string_google)
它是一个未记录的私有属性,您不应该使用它。但是,如果没有办法实现您想要的,您可以忽略该警告。您不应该使用该属性,它不是公共API的一部分