python程序中执行sql语句报错:columns = [col_desc[0] for col_desc in cursor.description] TypeError: 'NoneType' object is not iterable 解决方案


一、问题描述

  python程序中执行SQL语句时报错如下:columns = [col_desc[0] for col_desc in cursor.description]
TypeError: 'NoneType' object is not iterable

 

二、解决方案

  根据报错提示找到python目录下的sql.py文件,将

columns = [col_desc[0] for col_desc in cursor.description]

 

修改为: 

if not cursor.description:
    columns = []
else:
    columns = [col_desc[0] for col_desc in cursor.description]

 

文件路径:

问题解决。

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM