Commit 6961abb
authored
FEAT: Add Default Connection Pooling with User Opt-out Support (#118)
### ADO Work Item Reference
<!-- Insert your ADO Work Item ID below (e.g. AB#37452) -->
>
[AB#37846](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/37846)
-------------------------------------------------------------------
### Summary
<!-- Insert your Copilot Generated Summary below -->
This pull request introduces enhancements to the connection pooling
mechanism in the `mssql_python` package. Key changes include adding an
option to explicitly disable pooling, auto-enabling pooling if not
configured by the user, and introducing an initialization state to track
whether pooling has been set up.
### Connection pooling enhancements:
*
[`mssql_python/__init__.py`](diffhunk://#diff-d95f3a67986de29f30453416b1b4c34e6a43207e9a33e2b1b80ef0c378b0a538L57-R61):
Updated the `pooling` function to include an `enabled` parameter,
allowing explicit disabling of pooling. Added logic to disable pooling
when `enabled=False`.
[[1]](diffhunk://#diff-d95f3a67986de29f30453416b1b4c34e6a43207e9a33e2b1b80ef0c378b0a538L57-R61)
[[2]](diffhunk://#diff-d95f3a67986de29f30453416b1b4c34e6a43207e9a33e2b1b80ef0c378b0a538R70-R72)
*
[`mssql_python/connection.py`](diffhunk://#diff-29bb94de45aae51c23a6426d40133c28e4161e68769e08d046059c7186264e90R61-R63):
Added logic to auto-enable pooling during connection initialization if
the user has not explicitly configured pooling.
### Pooling manager improvements:
*
[`mssql_python/pooling.py`](diffhunk://#diff-e51a48b4bd1555a5e32a6d20c9c6331f6a6d99e309185b418d0c2c6fe2e26541R7):
Introduced `_initialized` state in `PoolingManager` to track whether
pooling has been configured. Added `disable` method to explicitly
disable pooling and updated `enable` method to set `_initialized` to
`True`. Added `is_initialized` method to check initialization state.
[[1]](diffhunk://#diff-e51a48b4bd1555a5e32a6d20c9c6331f6a6d99e309185b418d0c2c6fe2e26541R7)
[[2]](diffhunk://#diff-e51a48b4bd1555a5e32a6d20c9c6331f6a6d99e309185b418d0c2c6fe2e26541R27-R41)
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
-->1 parent fb0e7c1 commit 6961abb
3 files changed
+27
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments