FEAT: Adding timeout attribute #191
Open
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 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
timeout
parameter to theConnection
class and theconnect
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 theConnection
object.timeout
property in theConnection
class, including input validation and documentation. Setting the timeout updates all subsequently created cursors.cursor
method inConnection
to pass the current timeout value to each newCursor
instance.Cursor
class 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_TIMEOUT
constant and theDDBCSQLSetStmtAttr
function in the C++ driver bindings to support setting the timeout at the driver level.Testing and Validation