Skip to content

bulkcopy() & bulkcopy_arrow() fail with Schannel AcquireCredentialsHandleW error 0x8009030D (SEC_E_UNKNOWN_CREDENTIALS) #848

Open

Description

@oliveira-ruipedro

Hello ☺️

I have been trying to use mssql_python to read from and write to a SQL Server Database.

I am able to read with zero problems from the database and convert the data to Arrow. But, when I try to write back to the database using bulkcopy_arrow(), mssql_python raises the following error:

Failed to connect to SQL Server: Unexpected Implementation Error: Schannel AcquireCredentialsHandle failed: AcquireCredentialsHandleW(UNISP_NAME) failed: unknown SECURITY_STATUS (status=0x8009030D)

I have tried everything and nothing works, can you please help me?

Bellow i send more details about the bug:

On a client machine running Windows Server 2016 / Windows 10 1607 (build 14393), connecting to SQL Server 2022, a normal mssql_python.connect() session works perfectly — I can run SELECTs and executemany() inserts over it. But cursor.bulkcopy_arrow() always fails at connection time with a Schannel credential error:

Failed to connect to SQL Server: Unexpected Implementation Error: Schannel AcquireCredentialsHandle failed: AcquireCredentialsHandleW(UNISP_NAME) failed: unknown SECURITY_STATUS (status=0x8009030D)

0x8009030D is SEC_E_UNKNOWN_CREDENTIALS. This happens before any certificate validation, so it is distinct from the TLS cert-trust failures in #501 / #459 (which were fixed). The common root is the same design noted there: bulkcopy/bulkcopy_arrow open a separate mssql_py_core.PyCoreConnection instead of reusing the already-open, working connection, and that separate path negotiates TLS differently. On this older Windows build, the Rust client's TLS/Schannel credential acquisition fails outright.

I have ruled out the usual suspects — none of these change the result:

Meanwhile the exact same connection strings work fine for normal connect() + SELECT + executemany().

To reproduce

import mssql_python

conn = mssql_python.connect(
    "Server=<server>,1433;"
    "Database=<db>;"
    "Trusted_Connection=yes;"       # also tried UID=<user>;PWD=<pass>
    "TrustServerCertificate=yes;"   # also tried Encrypt=no
    "Encrypt=yes;"
)
cur = conn.cursor()

# This works fine
cur.execute("SELECT @@SERVERNAME, DB_NAME(), SUSER_SNAME()")
print(cur.fetchone())

# This works fine too
cur.executemany(
    "INSERT INTO <table> (col1, col2) VALUES (?, ?)",
    [(1, "a"), (2, "b")],
)
conn.commit()

# This FAILS at connection time:
#   Schannel AcquireCredentialsHandle failed:
#   AcquireCredentialsHandleW(UNISP_NAME) failed:
#   unknown SECURITY_STATUS (status=0x8009030D)
cur.bulkcopy_arrow("<table>", arrow_table, batch_size=1000)

Further technical details

  • mssql-python version: 1.16.0 (also reproduced on 1.15.0)
  • mssql-python-odbc: 18.6.2.2
  • mssql_python_rs: 0.3.0
  • Python: 3.10.4 (64-bit)
  • Client OS: Windows, build 10.0.14393 (Windows Server 2016 / Windows 10 1607), reported by platform.win32_ver() → ('10', '10.0.14393', 'SP0', 'Multiprocessor Free')
  • Auth: fails with both Trusted_Connection=yes and SQL login (UID/PWD)
  • SQL Server: Microsoft SQL Server 2022 (RTM-CU24) (KB5080999) - 16.0.4245.2 (X64)

Observations

  • Normal connection + SELECT + executemany all succeed on the same connection string.
  • Only the bulkcopy/bulkcopy_arrow path fails, and it fails at connect time (no data is sent).
  • Fails regardless of Encrypt=no vs Encrypt=yes;TrustServerCertificate=yes, and regardless of integrated vs SQL auth — consistent with the failure happening in Schannel credential acquisition, before certificate validation.

Possibly related: #501, #459 (separate PyCoreConnection, TLS handled differently than the main connection — but those were certificate-trust failures that are now fixed; this is a credential-acquisition failure on an older Windows build).

Workaround: cursor.executemany(...) + conn.commit() instead of bulk copy.

Activity

  1. changed the title [-]bulkcopy() & bulkcopy_arrow() fail on Windows Server 2016 (build 14393) with Schannel AcquireCredentialsHandleW error 0x8009030D (SEC_E_UNKNOWN_CREDENTIALS), while the normal connection works[/-] [+]bulkcopy() & bulkcopy_arrow() fail with Schannel AcquireCredentialsHandleW error 0x8009030D (SEC_E_UNKNOWN_CREDENTIALS)[/+] on Oct 16, 2026
  2. github-actions commented on Oct 16, 2026

    @github-actions

    Hi oliveira-ruipedro, thank you for opening this issue!

    Our team will review it shortly. We aim to triage all new issues within 24-48 hours and get back to you.

    If you have additional information to share, please feel free to update the issue.

    Thank you for your patience!

  3. jahnvi480 commented on Oct 20, 2026

    @jahnvi480
    Contributor

    oliveira-ruipedro Thanks for raising this issue, this matches a known limitation in our Rust TLS implementation: it uses SCH_CREDENTIALS, which requires Windows 10 version 1809 / Windows Server 2019 or later. Your client build, 14393 (Windows Server 2016 / Windows 10 1607), predates that API support.

    Normal queries work because they use the native ODBC driver, while both bulk-copy methods open a Rust-backed connection. That connection fails during Schannel credential initialization, before certificate validation or database authentication—so changing TrustServerCertificate or authentication methods will not resolve it.

    This restriction is currently noted in our implementation comments, but that is not sufficient user-facing documentation. We need to clarify the bulk-copy OS requirements and improve the error message. Supporting Server 2016 would require a compatible legacy Schannel credential path.

    For now, please use executemany() followed by commit(), or run bulk copy from a newer supported Windows client.

  4. oliveira-ruipedro commented on Oct 20, 2026

    @oliveira-ruipedro
    Author

    Jahnvi Thakkar (@jahnvi480) Thanks for the reply.

    So, unless I upgrade to Windows 10 version 1809 / Windows Server 2019, there will be no support for this issue in Windows Server 2016 / Windows 10 1607?

  5. jahnvi480 commented on Oct 20, 2026

    @jahnvi480
    Contributor

    oliveira-ruipedro Yes, we are planning to solve this but it might take time.

  6. oliveira-ruipedro commented on Oct 20, 2026

    @oliveira-ruipedro
    Author

    Jahnvi Thakkar (@jahnvi480) I will do the workaround for now and wait for a future PR from you side.

    Thanks, in advance, for the help you are providing 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: bulk-copyIssues in cursor.bulkcopy()bugSomething isn't workinginADOtriage doneIssues that are triaged by dev team and are in investigation.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions