aws-advanced-python-wrapper 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. aws_advanced_python_wrapper-1.0.0/CONTRIBUTING.md +63 -0
  2. aws_advanced_python_wrapper-1.0.0/LICENSE +201 -0
  3. aws_advanced_python_wrapper-1.0.0/PKG-INFO +261 -0
  4. aws_advanced_python_wrapper-1.0.0/README.md +225 -0
  5. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/__init__.py +28 -0
  6. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/aurora_connection_tracker_plugin.py +228 -0
  7. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/aurora_initial_connection_strategy_plugin.py +240 -0
  8. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/aws_secrets_manager_plugin.py +218 -0
  9. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/connect_time_plugin.py +69 -0
  10. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/connection_provider.py +232 -0
  11. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/database_dialect.py +708 -0
  12. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/default_plugin.py +144 -0
  13. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/developer_plugin.py +163 -0
  14. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/driver_configuration_profiles.py +44 -0
  15. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/driver_dialect.py +165 -0
  16. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/driver_dialect_codes.py +19 -0
  17. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/driver_dialect_manager.py +121 -0
  18. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/driver_info.py +18 -0
  19. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/errors.py +47 -0
  20. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/exception_handling.py +73 -0
  21. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/execute_time_plugin.py +58 -0
  22. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/failover_plugin.py +517 -0
  23. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/failover_result.py +42 -0
  24. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/fastest_response_strategy_plugin.py +345 -0
  25. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/federated_plugin.py +382 -0
  26. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/host_availability.py +86 -0
  27. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/host_list_provider.py +645 -0
  28. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/host_monitoring_plugin.py +728 -0
  29. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/host_selector.py +190 -0
  30. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/hostinfo.py +138 -0
  31. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/iam_plugin.py +195 -0
  32. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/mysql_driver_dialect.py +175 -0
  33. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/pep249.py +196 -0
  34. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/pg_driver_dialect.py +176 -0
  35. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/plugin.py +148 -0
  36. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/plugin_service.py +949 -0
  37. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/read_write_splitting_plugin.py +363 -0
  38. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/reader_failover_handler.py +252 -0
  39. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/resources/aws_advanced_python_wrapper_messages.properties +315 -0
  40. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/sql_alchemy_connection_provider.py +196 -0
  41. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/sqlalchemy_driver_dialect.py +127 -0
  42. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/stale_dns_plugin.py +209 -0
  43. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/states/__init__.py +13 -0
  44. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/states/session_state.py +94 -0
  45. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/states/session_state_service.py +221 -0
  46. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/__init__.py +13 -0
  47. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/atomic.py +51 -0
  48. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/cache_map.py +99 -0
  49. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/concurrent.py +100 -0
  50. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/decorators.py +70 -0
  51. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/failover_mode.py +39 -0
  52. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/iamutils.py +75 -0
  53. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/log.py +75 -0
  54. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/messages.py +36 -0
  55. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/mysql_exception_handler.py +73 -0
  56. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/notifications.py +37 -0
  57. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/pg_exception_handler.py +115 -0
  58. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/properties.py +492 -0
  59. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/rds_url_type.py +36 -0
  60. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/rdsutils.py +226 -0
  61. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/sliding_expiration_cache.py +146 -0
  62. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/telemetry/default_telemetry_factory.py +82 -0
  63. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/telemetry/null_telemetry.py +55 -0
  64. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/telemetry/open_telemetry.py +189 -0
  65. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/telemetry/telemetry.py +85 -0
  66. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py +126 -0
  67. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/utils/utils.py +89 -0
  68. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/wrapper.py +322 -0
  69. aws_advanced_python_wrapper-1.0.0/aws_advanced_python_wrapper/writer_failover_handler.py +347 -0
  70. aws_advanced_python_wrapper-1.0.0/pyproject.toml +78 -0
@@ -0,0 +1,63 @@
1
+ # Contributing Guidelines
2
+
3
+ Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4
+ documentation, we greatly value feedback and contributions from our community.
5
+
6
+ Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7
+ information to effectively respond to your bug report or contribution.
8
+
9
+
10
+ ## Reporting Bugs/Feature Requests
11
+
12
+ We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13
+
14
+ When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15
+ reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16
+
17
+ * A reproducible test case or series of steps
18
+ * The version of our code being used
19
+ * Any modifications you've made relevant to the bug
20
+ * Anything unusual about your environment or deployment
21
+
22
+
23
+ ## Contributing via Pull Requests
24
+
25
+ Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
26
+
27
+ 1. You are working against the latest source on the *main* branch.
28
+ 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
29
+ 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
30
+
31
+ To send us a pull request, please:
32
+
33
+ 1. Fork the repository.
34
+ 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
35
+ 3. Ensure local tests pass.
36
+ 4. Commit to your fork using clear commit messages.
37
+ 5. Send us a pull request, answering any default questions in the pull request interface.
38
+ 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
39
+
40
+ GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
41
+ [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
42
+
43
+
44
+ ## Finding contributions to work on
45
+
46
+ Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
47
+
48
+
49
+ ## Code of Conduct
50
+
51
+ This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
52
+ For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
53
+ opensource-codeofconduct@amazon.com with any additional questions or comments.
54
+
55
+
56
+ ## Security issue notifications
57
+
58
+ If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public GitHub issue.
59
+
60
+
61
+ ## Licensing
62
+
63
+ See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.1
2
+ Name: aws-advanced-python-wrapper
3
+ Version: 1.0.0
4
+ Summary: Amazon Web Services (AWS) Advanced Python Wrapper
5
+ Home-page: https://github.com/awslabs/aws-advanced-python-wrapper
6
+ License: Apache-2.0
7
+ Author: Amazon Web Services
8
+ Requires-Python: >=3.8.1,<4.0.0
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Requires-Dist: aws-xray-sdk (>=2.13.0,<3.0.0)
25
+ Requires-Dist: boto3 (>=1.34.107,<2.0.0)
26
+ Requires-Dist: opentelemetry-api (>=1.22.0,<2.0.0)
27
+ Requires-Dist: opentelemetry-sdk (>=1.22.0,<2.0.0)
28
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
29
+ Requires-Dist: resourcebundle (==2.1.0)
30
+ Requires-Dist: toml (>=0.10.2,<0.11.0)
31
+ Requires-Dist: types_aws_xray_sdk (>=2.13.0,<3.0.0)
32
+ Project-URL: Documentation, https://github.com/awslabs/aws-advanced-python-wrapper/docs/
33
+ Project-URL: Repository, https://github.com/awslabs/aws-advanced-python-wrapper
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Amazon Web Services (AWS) Advanced Python Driver
37
+
38
+ [![Build Status](https://github.com/awslabs/aws-advanced-python-wrapper/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/awslabs/aws-advanced-python-wrapper/actions/workflows/main.yml)
39
+ [![Integration Tests](https://github.com/awslabs/aws-advanced-python-wrapper/actions/workflows/integration_tests.yml/badge.svg?branch=main)](https://github.com/awslabs/aws-advanced-python-wrapper/actions/workflows/integration_tests.yml)
40
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
41
+
42
+ ## About the Driver
43
+
44
+ Hosting a database cluster in the cloud via Aurora is able to provide users with sets of features and configurations to obtain maximum performance and availability, such as database failover. However, at the moment, most existing drivers do not currently support those functionalities or are not able to entirely take advantage of it.
45
+
46
+ The main idea behind the AWS Advanced Python Driver is to add a software layer on top of an existing Python driver that would enable all the enhancements brought by Aurora, without requiring users to change their workflow with their databases and existing Python drivers.
47
+
48
+ ### What is Failover?
49
+
50
+ In an Amazon Aurora database cluster, **failover** is a mechanism by which Aurora automatically repairs the cluster status when a primary DB instance becomes unavailable. It achieves this goal by electing an Aurora Replica to become the new primary DB instance, so that the DB cluster can provide maximum availability to a primary read-write DB instance. The AWS Advanced Python Driver is designed to understand the situation and coordinate with the cluster in order to provide minimal downtime and allow connections to be very quickly restored in the event of a DB instance failure.
51
+
52
+ ### Benefits of the AWS Advanced Python Driver
53
+
54
+ Although Aurora is able to provide maximum availability through the use of failover, existing client drivers do not currently support this functionality. This is partially due to the time required for the DNS of the new primary DB instance to be fully resolved in order to properly direct the connection. The AWS Advanced Python Driver allows customers to continue using their existing community drivers in addition to having the AWS Advanced Python Driver fully exploit failover behavior by maintaining a cache of the Aurora cluster topology and each DB instance's role (Aurora Replica or primary DB instance). This topology is provided via a direct query to the Aurora DB, essentially providing a shortcut to bypass the delays caused by DNS resolution. With this knowledge, the AWS Advanced Python Driver can more closely monitor the Aurora DB cluster status so that a connection to the new primary DB instance can be established as fast as possible.
55
+
56
+ ### Enhanced Failure Monitoring
57
+
58
+ Since a database failover is usually identified by reaching a network or a connection timeout, the AWS Advanced Python Driver introduces an enhanced and customizable manner to faster identify a database outage.
59
+
60
+ Enhanced Failure Monitoring (EFM) is a feature available from the [Host Monitoring Connection Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md#enhanced-failure-monitoring) that periodically checks the connected database host's health and availability. If a database host is determined to be unhealthy, the connection is aborted (and potentially routed to another healthy host in the cluster).
61
+
62
+ ### Using the AWS Advanced Python Driver with plain RDS databases
63
+
64
+ The AWS Advanced Python Driver also works with RDS provided databases that are not Aurora.
65
+
66
+ Please visit [this page](./docs/using-the-python-driver/UsingThePythonDriver.md#using-the-aws-python-driver-with-plain-rds-databases) for more information.
67
+
68
+ ## Getting Started
69
+
70
+ To start using the driver with Psycopg, you need to pass Psycopg's connect function to the `AwsWrapperConnection#connect` method as shown in the following example:
71
+
72
+ ```python
73
+ from aws_advanced_python_wrapper import AwsWrapperConnection
74
+ from psycopg import Connection
75
+
76
+ with AwsWrapperConnection.connect(
77
+ Connection.connect,
78
+ "host=database.cluster-xyz.us-east-1.rds.amazonaws.com dbname=db user=john password=pwd",
79
+ plugins="failover",
80
+ wrapper_dialect="aurora-pg",
81
+ autocommit=True
82
+ ) as awsconn:
83
+ awscursor = awsconn.cursor()
84
+ awscursor.execute("SELECT aurora_db_instance_identifier()")
85
+ awscursor.fetchone()
86
+ for record in awscursor:
87
+ print(record)
88
+ ```
89
+ The `AwsWrapperConnection#connect` method accepts the connection configuration through both the connection string and the keyword arguments.
90
+
91
+ You can either pass the connection configuration entirely through the connection string, entirely though the keyword arguments, or through a mixture of both.
92
+
93
+ To use the driver with MySQL Connection/Python, see the following example:
94
+
95
+ ```python
96
+ from aws_advanced_python_wrapper import AwsWrapperConnection
97
+ from mysql.connector import Connect
98
+
99
+ with AwsWrapperConnection.connect(
100
+ Connect,
101
+ "host=database.cluster-xyz.us-east-1.rds.amazonaws.com database=db user=john password=pwd",
102
+ plugins="failover",
103
+ wrapper_dialect="aurora-mysql",
104
+ autocommit=True
105
+ ) as awsconn:
106
+ awscursor = awsconn.cursor()
107
+ awscursor.execute("SELECT @@aurora_server_id")
108
+ awscursor.fetchone()
109
+ for record in awscursor:
110
+ print(record)
111
+ ```
112
+
113
+ For more details on how to download the AWS Advanced Python Driver, minimum requirements to use it,
114
+ and how to integrate it within your project and with your Python driver of choice, please visit the
115
+ [Getting Started page](./docs/GettingStarted.md).
116
+
117
+ ### Connection Properties
118
+ The following table lists the connection properties used with the AWS Advanced Python Wrapper.
119
+
120
+ | Parameter | Documentation Link |
121
+ |----------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------:|
122
+ | `auxiliary_query_timeout_sec` | [Driver Parameters](./docs/using-the-python-driver/UsingThePythonDriver.md#aws-advanced-python-driver-parameters) |
123
+ | `topology_refresh_ms` | [Driver Parameters](./docs/using-the-python-driver/UsingThePythonDriver.md#aws-advanced-python-driver-parameters) |
124
+ | `cluster_id` | [Driver Parameters](./docs/using-the-python-driver/UsingThePythonDriver.md#aws-advanced-python-driver-parameters) |
125
+ | `cluster_instance_host_pattern` | [Driver Parameters](./docs/using-the-python-driver/UsingThePythonDriver.md#aws-advanced-python-driver-parameters) |
126
+ | `wrapper_dialect` | [Dialects](./docs/using-the-python-driver/DatabaseDialects.md), and whether you should include it. |
127
+ | `wrapper_driver_dialect` | [Driver Dialect](./docs/using-the-python-driver/DriverDialects.md), and whether you should include it. |
128
+ | `plugins` | [Connection Plugin Manager](./docs/using-the-python-driver/UsingThePythonDriver.md#connection-plugin-manager-parameters) |
129
+ | `auto_sort_wrapper_plugin_order` | [Connection Plugin Manager](./docs/using-the-python-driver/UsingThePythonDriver.md#connection-plugin-manager-parameters) |
130
+ | `profile_name` | [Connection Plugin Manager](./docs/using-the-python-driver/UsingThePythonDriver.md#connection-plugin-manager-parameters) |
131
+ | `connect_timeout` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
132
+ | `socket_timeout` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
133
+ | `tcp_keepalive` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
134
+ | `tcp_keepalive_time` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
135
+ | `tcp_keepalive_interval` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
136
+ | `tcp_keepalive_probes` | [Network Timeouts](./docs/using-the-python-driver/UsingThePythonDriver.md#network-timeouts) |
137
+ | `enable_failover` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
138
+ | `failover_mode` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
139
+ | `cluster_instance_host_pattern` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
140
+ | `failover_cluster_topology_refresh_rate_sec` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
141
+ | `failover_reader_connect_timeout_sec` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
142
+ | `failover_timeout_sec` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
143
+ | `failover_writer_reconnect_interval_sec` | [Failover Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md) |
144
+ | `failure_detection_count` | [Host Monitoring Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md) |
145
+ | `failure_detection_enabled` | [Host Monitoring Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md) |
146
+ | `failure_detection_interval_ms` | [Host Monitoring Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md) |
147
+ | `failure_detection_time_ms` | [Host Monitoring Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md) |
148
+ | `monitor_disposal_time_ms` | [Host Monitoring Plugin](./docs/using-the-python-driver/using-plugins/UsingTheHostMonitoringPlugin.md) |
149
+ | `iam_default_port` | [IAM Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheIamAuthenticationPlugin.md) |
150
+ | `iam_host` | [IAM Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheIamAuthenticationPlugin.md) |
151
+ | `iam_region` | [IAM Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheIamAuthenticationPlugin.md) |
152
+ | `iam_expiration` | [IAM Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheIamAuthenticationPlugin.md) |
153
+ | `secrets_manager_secret_id` | [Secrets Manager Plugin](./docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md) |
154
+ | `secrets_manager_region` | [Secrets Manager Plugin](./docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md) |
155
+ | `secrets_manager_endpoint` | [Secrets Manager Plugin](./docs/using-the-python-driver/using-plugins/UsingTheAwsSecretsManagerPlugin.md) |
156
+ | `reader_host_selector_strategy` | [Connection Strategy](./docs/using-the-python-driver/using-plugins/UsingTheReadWriteSplittingPlugin.md#connection-strategies) |
157
+ | `db_user` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
158
+ | `idp_username` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
159
+ | `idp_password` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
160
+ | `idp_endpoint` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
161
+ | `iam_role_arn` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
162
+ | `iam_idp_arn` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
163
+ | `iam_region` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
164
+ | `idp_name` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
165
+ | `idp_port` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
166
+ | `rp_identifier` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
167
+ | `iam_host` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
168
+ | `iam_default_port` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
169
+ | `iam_token_expiration` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
170
+ | `http_request_connect_timeout` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
171
+ | `ssl_secure` | [Federated Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md) |
172
+
173
+ ### Using the AWS Advanced Python Driver
174
+
175
+ Technical documentation regarding the functionality of the AWS Advanced Python Driver will be maintained in this GitHub repository. Since the AWS Advanced Python Driver requires an underlying Python driver, please refer to the individual driver's documentation for driver-specific information.
176
+ To find all the documentation and concrete examples on how to use the AWS Advanced Python Driver, please refer to the [AWS Advanced Python Driver Documentation](./docs/README.md) page.
177
+
178
+ ### Known Limitations
179
+
180
+ #### Amazon RDS Blue/Green Deployments
181
+
182
+ This driver currently does not support switchover in Amazon RDS Blue/Green Deployments. In order to execute a Blue/Green deployment with the driver,
183
+ please ensure your application is coded to retry the database connection. Retry will allow the driver to re-establish a connection to an available
184
+ database instance. Without a retry, the driver will not be able to identify an available database instance after blue/green switchover has occurred.
185
+
186
+ #### MySQL Connector/Python C Extension
187
+
188
+ When connecting to Aurora MySQL clusters, it is recommended to use the Python implementation of the MySQL Connector/Python driver by setting the `use_pure` connection argument to `True`.
189
+ The AWS Advanced Python Driver internally calls the MySQL Connector/Python's `is_connected` method to verify the connection. The [MySQL Connector/Python's C extension](https://dev.mysql.com/doc/connector-python/en/connector-python-cext.html) uses a network blocking implementation of the `is_connected` method.
190
+ In the event of a network failure where the host can no longer be reached, the `is_connected` call may hang indefinitely and will require users to forcibly interrupt the application.
191
+
192
+ #### MySQL Support for the IAM Authentication Plugin
193
+
194
+ The official MySQL Connector/Python [offers a Python implementation and a C implementation](https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html#:~:text=Using%20the%20Connector/Python%20Python%20or%20C%20Extension) of the driver that can be toggled using the `use_pure` connection argument.
195
+ The [IAM Authentication Plugin](./docs/using-the-python-driver/using-plugins/UsingTheIamAuthenticationPlugin.md) is incompatible with the Python implementation of the driver due to its 255-character password limit.
196
+ The IAM Authentication Plugin generates a temporary AWS IAM token to authenticate users. Passing this token to the Python implementation of the driver will result in the following error:
197
+ `struct.error: ubyte format requires 0 <= number <= 255`. To avoid this error, we recommend you set `use_pure` to `False` when using the IAM Authentication Plugin.
198
+ However, as noted in the [MySQL Connector/Python C Extension](#mysql-connectorpython-c-extension) section, doing so may cause the application to indefinitely hang if there is a network failure.
199
+ Unfortunately, due to conflicting limitations, you will need to decide if using the IAM plugin is worth this risk for your application.
200
+
201
+ #### Toxiproxy network failure behavior
202
+
203
+ In the AWS Advanced Python Driver test suite, we have two methods of simulating database/network failure:
204
+ - method 1: initiate failover using the AWS RDS SDK.
205
+ - method 2: use a test dependency called Toxiproxy.
206
+
207
+ Toxiproxy creates proxy network containers that sit between the test and the actual database. The test code connects to the proxy containers instead of the database. Toxiproxy can then be used to disable network activity between the driver and the database via the proxy. This network failure simulation is stricter than scenario 1. It does not allow any communication between the driver and the database, and does not give the database a chance to break off any connections.
208
+
209
+ We have observed different behavior when testing with method 1 vs method 2. With method 1, the server failover is detected without unexpected side effects. With method 2, we have observed some side effects. We have only observed these side effects when using Toxiproxy, and have never observed them in a real-world scenario.
210
+
211
+ Psycopg and MySQL Connector/Python do not provide client-side query timeouts. When querying a host that has been disabled via Toxiproxy, the query will hang indefinitely until the host is re-enabled. Whether this behavior would ever occur in a real world scenario is uncertain. We reached out to the Psycopg team, who indicated they have not seen this issue (see full discussion [here](https://github.com/psycopg/psycopg/discussions/676)). They also believe that Toxiproxy tests for stricter conditions than would occur in a real-world scenario. However, we will list the side effects we have noticed during testing due to this behavior:
212
+
213
+ 1. The EFM plugin and `socket_timeout` connection parameter use helper threads to execute queries used to detect if the network is working properly. These helper threads are executed with a timeout so that failure can be detected if the network is down. If the host was disabled using Toxiproxy, although the timeout will return control to the main thread, the helper thread will be stuck in a loop waiting on results from the server. It will be stuck until the host is re-enabled with Toxiproxy. There is no mechanism to cancel a running thread from another thread in Python, so the thread will consume resources until the host is re-enabled. Using an Event to signal the thread to stop is not an option, as the loop occurs inside the underlying driver code. Note that although the helper thread will be stuck, control will still be returned to the main thread so that the driver is still usable.
214
+ 2. As a consequence of side effect 1, if a query is executed against a host that has been disabled with Toxiproxy, the Python program will not exit if the host is not re-enabled. The EFM helper threads mentioned in side effect 1 are run using a ThreadPoolExecutor. Although the ThreadPoolExecutor implementation uses daemon threads, it also joins all threads at Python exit. Because the helper thread is stuck in this scenario, the Python application will hang waiting the thread to join. This behavior has only been observed when using the MySQL Connector/Python driver.
215
+ 3. As a consequence of side effect 1, if a query is executed against a host that has been disabled with Toxiproxy, and the host is still disabled when the Python program exits, a segfault may occur. This occurs because the helper thread is stuck in a loop attempting to read a connection pointer. When the program is exiting, the pointer is destroyed. The helper thread may try to read from the pointer after it is destroyed, leading to a segfault. This behavior has only been observed when using the Psycopg driver.
216
+
217
+ ## Getting Help and Opening Issues
218
+
219
+ If you encounter a bug with the AWS Advanced Python Driver, we would like to hear about it.
220
+ Please search the [existing issues](https://github.com/awslabs/aws-advanced-python-wrapper/issues) to see if others are also experiencing the issue before reporting the problem in a new issue. GitHub issues are intended for bug reports and feature requests.
221
+
222
+ When opening a new issue, please fill in all required fields in the issue template to help expedite the investigation process.
223
+
224
+ For all other questions, please use [GitHub discussions](https://github.com/awslabs/aws-advanced-python-wrapper/discussions).
225
+
226
+ ## How to Contribute
227
+
228
+ 1. Set up your environment by following the directions in the [Development Guide](./docs/development-guide/DevelopmentGuide.md).
229
+ 2. To contribute, first make a fork of this project.
230
+ 3. Make any changes on your fork. Make sure you are aware of the requirements for the project (e.g. do not require Python 3.7 if we are supporting Python 3.8 and higher).
231
+ 4. Create a pull request from your fork.
232
+ 5. Pull requests need to be approved and merged by maintainers into the main branch. <br />
233
+
234
+ > [!NOTE]\
235
+ > Before making a pull request, [run all tests](./docs/development-guide/DevelopmentGuide.md#running-the-tests) and verify everything is passing.
236
+
237
+ ### Code Style
238
+
239
+ The project source code is written using the [PEP 8 Style Guide](https://peps.python.org/pep-0008/), and the style is strictly enforced in our automation pipelines. Any contribution that does not respect/satisfy the style will automatically fail at build time.
240
+
241
+ ## Releases
242
+
243
+ The `aws-advanced-python-wrapper` has a regular monthly release cadence. A new release will occur during the last week of each month. However, if there are no changes since the latest release, then a release will not occur.
244
+
245
+ ## Aurora Engine Version Testing
246
+
247
+ This `aws-advanced-python-wrapper` is being tested against the following Community and Aurora database versions in our test suite:
248
+
249
+ | Database | Versions |
250
+ |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
251
+ | MySQL | 8.3.0 |
252
+ | PostgreSQL | 16.2 |
253
+ | Aurora MySQL | - LTS version, see [here](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.Versions.html#AuroraMySQL.Updates.LTS) for more details. <br><br> - Latest release, as shown on [this page](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/AuroraMySQL.Updates.30Updates.html). |
254
+ | Aurora PostgreSQL | - LTS version, see [here](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.LTS.html) for more details. <br><br> - Latest release, as shown on [this page](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraPostgreSQLReleaseNotes/AuroraPostgreSQL.Updates.html).) |
255
+
256
+ The `aws-advanced-python-wrapper` is compatible with MySQL 5.7 and MySQL 8.0 as per MySQL Connector/Python.
257
+
258
+ ## License
259
+
260
+ This software is released under the Apache 2.0 license.
261
+