python - PEP8 清理 - 访问一个类的受保护成员 _last_executed
问题描述
我有下面的代码块,它捕获警告几种不同的查询类型并将它们写入很多,如果它们失败/警告,则向我发送谷歌聊天消息。我收到 pep8 错误str(cursor._last_executed)
:
访问类的受保护成员 _last_executed
我需要对此进行更改吗?它确实做我想做的事 - 将失败的 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)
解决方案
推荐阅读
- java - java中线程的等待和通知序列
- suitecrm - suiteCRM 中每个模块类型的描述
- javascript - 如何让我的 html 元素不参与 elementFromPoint
- java - 用单斜杠“/”替换斜杠之间的点,即“/./”
- angularjs - 添加自定义字段,但在呈现表单时避免使用 angularjs 正式包装器
- r - 如何为大小设置单独的图例并填写 ggplot
- javascript - 如何在 ReactJS 中生成嵌入式代码?
- php - 如何获取 url 的最后一部分并构建重定向?
- r - 基本 R 问题 - while 循环中的可更新输入
- c# - 使用 SHA256 在 C# 中签名文本