Skip to content

Insert None with executemany is not supported #273

@Tweentyy

Description

@Tweentyy

Describe the bug

When inserting a column that accepts NULL values with the value None, an error is returned.

Exception message: Exception: RuntimeError: BindParameterArray: Unsupported C type: 99
Stack trace:
[2025-10-02T10:57:39.569Z]   File "/Users/tweenty/Desktop/XXX/test.py", line 31, in insert_data
[2025-10-02T10:57:39.570Z]     cursor.executemany("INSERT INTO TestSQL (TestValue) VALUES (?)", data)
[2025-10-02T10:57:39.570Z]   File "/Users/tweenty/Desktop/XXX/.venv/lib/python3.12/site-packages/mssql_python/cursor.py", line 1682, in executemany
[2025-10-02T10:57:39.570Z]     ret = ddbc_bindings.SQLExecuteMany(
[2025-10-02T10:57:39.570Z] .

To reproduce

Create a table with Nullable column:

CREATE TABLE TestSQL (
      TestValue VARCHAR(50)
)
data = [(None,), (None,)]

cursor.execute("INSERT INTO TestSQL (TestValue) VALUES (?)", data[0]) # Works
cursor.executemany("INSERT INTO TestSQL (TestValue) VALUES (?)", data) # Doesn't work

Expected behavior

Insertion of lines into database.
I have tested with a Decimal column, it's not working so maybe it's a general problem.

Further technical details

Python version: 3.12.10
SQL Server version: SQL Server 2022
Operating system: macOS 26.0.1
mssql_python version: 0.13.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage doneIssues that are triaged by dev team and are in investigation.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions