You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Work Item / Issue Reference <!-- IMPORTANT: Please follow the PR template guidelines below. For mssql-python maintainers: Insert your ADO Work Item ID below (e.g. AB#37452) For external contributors: Insert Github Issue number below (e.g. #149) Only one reference is required - either GitHub issue OR ADO Work Item. --> <!-- mssql-python maintainers: ADO Work Item --> > [AB#34910](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/34910) ------------------------------------------------------------------- ### 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** * Added a `timeout` parameter to the `Connection` class and the `connect` function, 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 the `Connection` object. * Implemented getter and setter for the `timeout` property in the `Connection` class, including input validation and documentation. Setting the timeout updates all subsequently created cursors. * Modified the `cursor` method in `Connection` to pass the current timeout value to each new `Cursor` instance. * Updated the `Cursor` class to accept a timeout parameter and, if set, apply it to each query execution using the underlying driver’s statement attribute API. * Exposed the `SQL_ATTR_QUERY_TIMEOUT` constant and the `DDBCSQLSetStmtAttr` function in the C++ driver bindings to support setting the timeout at the driver level. **Testing and Validation** * Added comprehensive tests to verify default timeout behavior, setting and getting the timeout property, passing timeout via the constructor, enforcing timeout on long-running queries, and ensuring that updating the connection timeout affects all new cursors. --------- Co-authored-by: Jahnvi Thakkar <jathakkar@microsoft.com>
0 commit comments