Skip to content

Bulk Copy Handles Decimal Inconsistently Compared with Normal Queries #457

Description

Describe the bug

Trying to insert into a Decimal column with the new bulk_copy can throw an exception regarding mismatched decimal scale, whereas a normal insert will succeed and automatically deal with the issue. I would like to see bulk_copy work similarly and seamlessly.

To reproduce

import mssql_python
from decimal import Decimal

conn = mssql_python.connect([conn string], autocommit=True)
cur = conn.cursor()
cur.execute('create table dectest (d decimal(10, 2));')

# This next line works fine
cur.execute('insert into dectest values (?)', Decimal('123.456'))

# This line fails with the below exception
cur.bulkcopy('dectest', (Decimal('123.456'),))

Exception message

ValueError: Input decimal scale 3 exceeds target scale 2

Expected behavior

The bulkcopy should succeed and the value should be automatically rounded as it is in the insert.

Activity

  1. github-actions commented on Feb 27, 2026

    @github-actions

    Hi Adam Machanic (@amachanic), 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!

  2. saurabh500 commented on Feb 28, 2026

    @saurabh500
    Contributor

    Thanks. We were conservative in conversions in bulkcopy for Decimal. The feedback makes sense. We can alleviate this restriction.

  3. amachanic commented on Aug 7, 2026

    @amachanic
    Author

    Any updates here? Just hit this again today and had to work around. Kind of annoying. Would definitely appreciate a fix!

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()triage neededFor new issues, not triaged yet.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions