FEAT: Adding Cursor.connection attribute#165
Merged
jahnvi480 merged 2 commits intojahnvi/cursor_rownumberfrom Aug 6, 2025
Merged
FEAT: Adding Cursor.connection attribute#165jahnvi480 merged 2 commits intojahnvi/cursor_rownumberfrom
jahnvi480 merged 2 commits intojahnvi/cursor_rownumberfrom
Conversation
bewithgaurav
approved these changes
Aug 5, 2025
sumitmsft
approved these changes
Aug 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request introduces the DB-API 2.0-compliant
connectionattribute to theCursorclass inmssql_python, ensuring that each cursor exposes a read-only reference to its parent connection. The implementation is thoroughly tested with new and updated test cases covering polymorphic code, multi-cursor scenarios, connection lifecycle, and transaction control.DB-API 2.0 compliance and attribute exposure
connectionproperty to theCursorclass, exposing the connection object used to create the cursor, and updated internal usage to store the connection as a private attribute (_connection). (mssql_python/cursor.py) [1] [2]Internal refactoring
self.connectiontoself._connectionto enforce encapsulation and ensure the public attribute is read-only. (mssql_python/cursor.py)Test coverage for the new attribute
cursor.connectionattribute, including multi-cursor and multi-connection environments, accessibility after cursor/connection closure, and polymorphic code examples. (tests/test_004_cursor.py)Transaction and polymorphic usage examples
cursor.connectionattribute, confirming correct behavior in real-world scenarios. (tests/test_004_cursor.py)