【问题标题】:Why is calling cursor.executemany() with fast_executemany=True resulting in a segmentation fault?为什么用 fast_executemany=True 调用 cursor.executemany() 会导致分段错误?
【发布时间】:2019-01-08 03:11:15
【问题描述】:

我有一个 pydodbc 游标连接到 Azure SQL 数据库,并在 Mac OS Sierra 10.12.6 上安装了最新版本的 FreeTDS:

cursor.execute("CREATE TABLE test(a INT, b INT)")
cursor.commit()

这行,很好,那我试试

cursor.fast_executemany=True
cursor.execute("INSERT INTO test(a, b) VALUES(?,?)", [(1,2),(3,4),(5,6)])

这会导致分段错误,我看到的唯一错误消息是segmentation fault: 11

如果我不设置cursor.fast_executemany=True,那么代码就可以正常工作。

【问题讨论】:

    标签: python segmentation-fault pyodbc freetds


    【解决方案1】:

    我能够使用 FreeTDS 1.00.94 和 unixODBC 2.3.6 在 Xubuntu 16.04 下重现您的“分段错误”问题。

    fast_executemany = True 使用称为“参数数组”的 ODBC 功能,并非所有 ODBC 驱动程序都支持该功能。显然 FreeTDS ODBC 是不支持它的驱动程序之一。

    如果你真的需要使用fast_executemany = True,你可以使用Microsoft's ODBC Driver for SQL Server。它确实支持 ODBC 参数数组。

    【讨论】:

      猜你喜欢
      • 2021-07-18
      • 2020-04-15
      • 1970-01-01
      • 1970-01-01
      • 2021-05-29
      • 2020-10-28
      • 1970-01-01
      • 2017-08-18
      • 2015-01-18
      相关资源
      最近更新 更多