-
Notifications
You must be signed in to change notification settings - Fork 31
FEAT: Adding timeout attribute #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sumitmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment. Rest all looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds query timeout functionality to the MSSQL Python driver, allowing users to set timeout values at the connection level that apply to all cursors created from that connection.
- Added timeout parameter to Connection class and connect function with proper validation
- Implemented timeout enforcement in cursor execute/executemany methods using SQL_ATTR_QUERY_TIMEOUT
- Exposed necessary C++ driver bindings for setting statement attributes
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mssql_python/db_connection.py | Added timeout parameter to connect function |
| mssql_python/connection.py | Added timeout property with getter/setter and passed to cursor creation |
| mssql_python/cursor.py | Added timeout support in execute/executemany methods |
| mssql_python/constants.py | Added SQL_ATTR_QUERY_TIMEOUT constant |
| mssql_python/pybind/ddbc_bindings.cpp | Exposed DDBCSQLSetStmtAttr function for setting statement attributes |
| tests/test_003_connection.py | Added test imports and cleanup fixture |
| tests/test_004_cursor.py | Added comprehensive tests for decimal separator functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Work Item / Issue Reference
Summary
This pull request adds support for per-connection query timeouts to the MSSQL Python driver. Now, you can set a timeout value on a connection, either at creation or later, and all cursors created from that connection will enforce this timeout for query execution. The changes include updates to the connection and cursor classes, integration with the underlying driver, and comprehensive tests for the new functionality.
Query Timeout Support
timeoutparameter to theConnectionclass and theconnectfunction, allowing users to specify a query timeout (in seconds) when establishing a database connection. The timeout can also be set or updated via a property on theConnectionobject.timeoutproperty in theConnectionclass, including input validation and documentation. Setting the timeout updates all subsequently created cursors.cursormethod inConnectionto pass the current timeout value to each newCursorinstance.Cursorclass to accept a timeout parameter and, if set, apply it to each query execution using the underlying driver’s statement attribute API.SQL_ATTR_QUERY_TIMEOUTconstant and theDDBCSQLSetStmtAttrfunction in the C++ driver bindings to support setting the timeout at the driver level.Testing and Validation