Skip to content

Comments

FEAT: Remove invalid DATABASE requirement check in bulk copy#443

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-invalid-db-check-bulkcopy
Closed

FEAT: Remove invalid DATABASE requirement check in bulk copy#443
Copilot wants to merge 2 commits intomainfrom
copilot/fix-invalid-db-check-bulkcopy

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

Work Item / Issue Reference

GitHub Issue: #442

Summary

DATABASE is optional in ODBC connection strings — omitting it causes the server to use the client's default database, which is valid behavior. The _bulkcopy method was incorrectly rejecting such connection strings with a hard error, while regular ODBC connections using the same string worked fine.

Changes

  • mssql_python/cursor.py: Removed the ValueError guard that blocked bulk copy when DATABASE was absent from the connection string.
Original prompt

This section details on the original issue you should resolve

<issue_title>Invalid check for database in connection string in _bulkcopy</issue_title>
<issue_description>### Describe the bug
A clear and concise description of what the bug is.

If you are seeing an exception, include the full exceptions details (message and stack trace).

The database keyword in connection string is optional. In its absence the client sends an empty database name and server responds with the database which the client was connected to. This default DB has been master.

In _bulkcopy we have a check to error out if the DATABASE in the connection string is not specified.

https://github.com/microsoft/mssql-python/blame/f8a6ca130e80d7180395e0e20a1c01e11641f38a/mssql_python/cursor.py#L2630C9-L2634C14

This needs to be removed.

The impact is that a connection string without database (though rare but possible), allows an ODBC connection, but the same connection string wont allow a bulk copy operation.

Please remove this check.</issue_description>

<agent_instructions>Take a look at the issue description and then delete the lines in the file that the issue calls out.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: saurabh500 <1623701+saurabh500@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix invalid check for database in connection string in bulkcopy Remove invalid DATABASE requirement check in bulk copy Feb 21, 2026
Copilot AI requested a review from saurabh500 February 21, 2026 00:54
@saurabh500 saurabh500 changed the title Remove invalid DATABASE requirement check in bulk copy FEAT: Remove invalid DATABASE requirement check in bulk copy Feb 21, 2026
@github-actions github-actions bot added the pr-size: small Minimal code update label Feb 21, 2026
@saurabh500 saurabh500 closed this Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid check for database in connection string in _bulkcopy

2 participants