【问题标题】:Containerized python script fails with StopIteration容器化 python 脚本因 StopIteration 失败
【发布时间】:2022-01-07 22:49:50
【问题描述】:

我正在尝试编写一个 python 脚本,它以顺序方式加载一系列 sql 文件。

它在我的本地机器上运行没有问题,但是一旦从容器中执行它就会失败。

受影响的代码

iterator = db_cursor.execute(sql_file.read(), multi=True)
            for res in iterator:
                logger.debug("executing query: [%s], affected %d rows", res, res.rowcount)
            iterator.close()

错误

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/dist-packages/mysql/connector/cursor.py", line 486, in _execute_iter

    result = next(query_iter)

StopIteration


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/migration.py", line 91, in <module>

    for res in iterator:

RuntimeError: generator raised StopIteration

关于如何纠正它的任何建议? 谢谢。

编辑 看起来这是我正在使用的库中的一个错误。注意到我一直在本地机器上使用mysql-connector-python,在远程机器上使用mysql-connector

已解决

【问题讨论】:

    标签: python mysql-connector stopiteration


    【解决方案1】:

    看起来这是我使用的库中的一个错误。注意到我一直在本地机器上使用 mysql-connector-python,在远程机器上使用 mysql-connector。

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 2020-02-11
      • 2015-09-18
      相关资源
      最近更新 更多