python - 防止 mysql.cursor.fetchall() 抛出 ValueError?
问题描述
所以,这是我的代码:
mysql_cur.execute("select * from view_john")
mysql_data = mysql_cur.fetchall()
这是我得到的输出:
ValueError: invalid literal for int() with base 0: '000551'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./xyz.py", line 36, in <module>
mysql_data = mysql_cur.fetchall()
File "/home/john/.local/lib/python3.8/site-packages/mysql/connector/cursor_cext.py", line 490, in fetchall
rows = self._cnx.get_rows()
File "/home/john/.local/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 318, in get_rows
else self._cmysql.fetch_row()
SystemError: <method 'fetch_row' of '_mysql_connector.MySQL' objects> returned a result with an error set
我能做些什么来防止这种情况发生?我可以在执行 SELECT 查询时临时更改列类型吗?
解决方案
推荐阅读
- javascript - 如何在 Ace Editor 的滚动条上标记线条
- json - 使用 Visual Basic 在电子表格中编写代码
- c# - 铸造通用委托动作
行动 - reactjs - 使用 Enzyme 和 Jest 测试 Material-UI Select 控件
- spring - 检测 Spring Boot Web 中的封闭通信
- python - 如何修复 ValueError:没有足够的值在 python 中解包(预期 3,得到 2)
- python - 如何根据 2 个自定义列表对数据集进行排序?
- android - 如何让我的 localhost 为我的 android 模拟器工作?
- python - 错误:“utf-8”编解码器无法解码位置 0 中的字节 0xb0:google colab 中的无效起始字节
- android - 如何在 TimePickerDilog kotlin 中禁用过去的时间