Skip to content

Commit 9408398

Browse files
authored
docs: srw (#1049)
1 parent 5dc424b commit 9408398

13 files changed

Lines changed: 432 additions & 54 deletions

Maintenance.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Release Schedule
22

3-
| Release Date | Release |
4-
|-------------------|--------------------------------------------------------------------------------------------|
5-
| May 16, 2024 | [Release 1.0.0](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.0.0) |
6-
| July 31, 2024 | [Release 1.1.0](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.1.0) |
7-
| October 18, 2024 | [Release 1.1.1](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.1.1) |
8-
| December 12, 2024 | [Release 1.2.0](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.2.0) |
9-
| July 28, 2025 | [Release 1.3.0](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.3.0) |
10-
| October 17, 2025 | [Release 1.4.0](https://github.com/awslabs/aws-advanced-python-wrapper/releases/tag/1.4.0) |
3+
| Release Date | Release |
4+
|-------------------|----------------------------------------------------------------------------------------|
5+
| May 16, 2024 | [Release 1.0.0](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.0.0) |
6+
| July 31, 2024 | [Release 1.1.0](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.1.0) |
7+
| October 18, 2024 | [Release 1.1.1](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.1.1) |
8+
| December 12, 2024 | [Release 1.2.0](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.2.0) |
9+
| July 28, 2025 | [Release 1.3.0](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.3.0) |
10+
| October 17, 2025 | [Release 1.4.0](https://github.com/aws/aws-advanced-python-wrapper/releases/tag/1.4.0) |
1111

1212
`aws-advanced-python-wrapper` [follows semver](https://semver.org/#semantic-versioning-200) which means we will only
1313
release breaking changes in major versions. Generally speaking patches will be released to fix existing problems without

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Enhanced Failure Monitoring (EFM) is a feature available from the [Host Monitori
3030

3131
The AWS Advanced Python Driver also works with RDS provided databases that are not Aurora.
3232

33-
Please visit [this page](./docs/using-the-python-driver/UsingThePythonDriver.md#using-the-aws-python-driver-with-plain-rds-databases) for more information.
33+
Please visit [this page](./docs/using-the-python-driver/UsingThePythonDriver.md#using-the-aws-advanced-python-driver-with-plain-rds-databases) for more information.
3434

3535
## Getting Started
3636

@@ -195,11 +195,11 @@ Psycopg and MySQL Connector/Python do not provide client-side query timeouts. Wh
195195
## Getting Help and Opening Issues
196196

197197
If you encounter a bug with the AWS Advanced Python Driver, we would like to hear about it.
198-
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.
198+
Please search the [existing issues](https://github.com/aws/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.
199199

200200
When opening a new issue, please fill in all required fields in the issue template to help expedite the investigation process.
201201

202-
For all other questions, please use [GitHub discussions](https://github.com/awslabs/aws-advanced-python-wrapper/discussions).
202+
For all other questions, please use [GitHub discussions](https://github.com/aws/aws-advanced-python-wrapper/discussions).
203203

204204
## How to Contribute
205205

benchmarks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The benchmarks do not measure the performance of target Python drivers nor the p
1111

1212
## Benchmark Results
1313

14-
Tests ran on commit [3d473f6c12f495762d3b7436a97a0e6bd76361d7](https://github.com/awslabs/aws-advanced-python-wrapper/commit/3d473f6c12f495762d3b7436a97a0e6bd76361d7)
14+
Tests ran on commit [3d473f6c12f495762d3b7436a97a0e6bd76361d7](https://github.com/aws/aws-advanced-python-wrapper/commit/3d473f6c12f495762d3b7436a97a0e6bd76361d7)
1515

1616
## Summary
1717
| Benchmark | Overhead |

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- [Federated Authentication Plugin](./using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md)
2222
- [Read Write Splitting Plugin](./using-the-python-driver/using-plugins/UsingTheReadWriteSplittingPlugin.md)
2323
- [Reader Selection Strategies](./using-the-python-driver/ReaderSelectionStrategies.md)
24+
- [Simple Read Write Splitting Plugin](./using-the-python-driver/using-plugins/UsingTheSimpleReadWriteSplittingPlugin.md)
2425
- [Fastest Response Strategy Plugin](./using-the-python-driver/using-plugins/UsingTheFastestResponseStrategyPlugin.md)
2526
- [Host Availability Strategy](./using-the-python-driver/HostAvailabilityStrategy.md)
2627
- [Development Guide](./development-guide/DevelopmentGuide.md)

docs/development-guide/DevelopmentGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Make sure you have Python 3.10 - 3.13 (inclusive) installed, along with your cho
66
Clone the AWS Advanced Python Driver repository:
77

88
```bash
9-
git clone https://github.com/awslabs/aws-advanced-python-wrapper.git
9+
git clone https://github.com/aws/aws-advanced-python-wrapper.git
1010
```
1111

1212
You can now make changes in the repository.

docs/examples/MySQLFailover.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
4040

4141
except FailoverSuccessError:
4242
# Query execution failed and AWS Advanced Python Driver successfully failed over to an available instance.
43-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---successful-failover
43+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoversuccesserror
4444

4545
# The old cursor is no longer reusable and the application needs to reconfigure sessions states.
4646
configure_initial_session_states(conn)
@@ -51,12 +51,12 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
5151

5252
except FailoverFailedError as e:
5353
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
54-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---unable-to-establish-sql-connection
54+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
5555
raise e
5656

5757
except TransactionResolutionUnknownError as e:
5858
# User application should check the status of the failed transaction and restart it if needed. See:
59-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#TransactionResolutionUnknownError---transaction-resolution-unknown
59+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror
6060
raise e
6161

6262

docs/examples/MySQLReadWriteSplitting.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from aws_advanced_python_wrapper.hostinfo import HostInfo
2121
from aws_advanced_python_wrapper.pep249 import Connection
2222

23-
import mysql.connector
23+
import mysql.connector # type: ignore
2424

2525
from aws_advanced_python_wrapper import AwsWrapperConnection
2626
from aws_advanced_python_wrapper.connection_provider import \
@@ -58,7 +58,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
5858

5959
except FailoverSuccessError:
6060
# Query execution failed and AWS Advanced Python Driver successfully failed over to an available instance.
61-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---successful-failover
61+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoversuccesserror
6262

6363
# The old cursor is no longer reusable and the application needs to reconfigure sessions states.
6464
configure_initial_session_states(conn)
@@ -69,12 +69,12 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
6969

7070
except FailoverFailedError as e:
7171
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
72-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---unable-to-establish-sql-connection
72+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
7373
raise e
7474

7575
except TransactionResolutionUnknownError as e:
7676
# User application should check the status of the failed transaction and restart it if needed. See:
77-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#TransactionResolutionUnknownError---transaction-resolution-unknown
77+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror
7878
raise e
7979

8080

@@ -86,7 +86,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
8686
"password": "pwd",
8787
"plugins": "read_write_splitting,failover",
8888
"wrapper_dialect": "aurora-mysql",
89-
"autocommit": True
89+
"autocommit": True,
9090
}
9191

9292
"""
@@ -101,26 +101,38 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
101101
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
102102
configure_initial_session_states(conn)
103103
execute_queries_with_failover_handling(
104-
conn, "CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)")
104+
conn,
105+
"CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)",
106+
)
105107
execute_queries_with_failover_handling(
106-
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200))
108+
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200)
109+
)
107110
execute_queries_with_failover_handling(
108-
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200))
111+
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200)
112+
)
109113

110114
""" Example step: open connection and perform transaction """
111115
try:
112116
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn, conn.cursor() as cursor:
113117
configure_initial_session_states(conn)
114118

115119
execute_queries_with_failover_handling(
116-
conn, "UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s", ("Jane Doe",))
120+
conn,
121+
"UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s",
122+
("Jane Doe",),
123+
)
117124
execute_queries_with_failover_handling(
118-
conn, "UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s", ("John Smith",))
125+
conn,
126+
"UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s",
127+
("John Smith",),
128+
)
119129

120130
# Internally switch to a reader connection
121131
conn.read_only = True
122132
for i in range(2):
123-
cursor = execute_queries_with_failover_handling(conn, "SELECT * FROM bank_test WHERE id = %s", (i,))
133+
cursor = execute_queries_with_failover_handling(
134+
conn, "SELECT * FROM bank_test WHERE id = %s", (i,)
135+
)
124136
for record in cursor:
125137
print(record)
126138

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License").
4+
# You may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union
18+
19+
if TYPE_CHECKING:
20+
from aws_advanced_python_wrapper.pep249 import Connection
21+
22+
import mysql.connector # type: ignore
23+
24+
from aws_advanced_python_wrapper import AwsWrapperConnection
25+
from aws_advanced_python_wrapper.errors import (
26+
FailoverFailedError, FailoverSuccessError,
27+
TransactionResolutionUnknownError)
28+
29+
def configure_initial_session_states(conn: Connection):
30+
awscursor = conn.cursor()
31+
awscursor.execute("SET time_zone = 'UTC'")
32+
33+
34+
def execute_queries_with_failover_handling(conn: Connection, sql: str, params: Optional[Union[Dict, Tuple]] = None):
35+
try:
36+
cursor = conn.cursor()
37+
cursor.execute(sql, params)
38+
return cursor
39+
40+
except FailoverSuccessError:
41+
# Query execution failed and AWS Advanced Python Driver successfully failed over to an available instance.
42+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoversuccesserror
43+
44+
# The old cursor is no longer reusable and the application needs to reconfigure sessions states.
45+
configure_initial_session_states(conn)
46+
# Retry query
47+
cursor = conn.cursor()
48+
cursor.execute(sql)
49+
return cursor
50+
51+
except FailoverFailedError as e:
52+
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
53+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
54+
raise e
55+
56+
except TransactionResolutionUnknownError as e:
57+
# User application should check the status of the failed transaction and restart it if needed. See:
58+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror
59+
raise e
60+
61+
62+
if __name__ == "__main__":
63+
params = {
64+
"host": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
65+
"database": "mysql",
66+
"user": "admin",
67+
"password": "pwd",
68+
"plugins": "srw,failover",
69+
"srw_write_endpoint": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com", # Replace with write endpoint
70+
"srw_read_endpoint": "rds-proxy-name-read-only.endpoint.proxy-xyz.us-east-1.rds.amazonaws.com", # Replace with read endpoint
71+
"srw_verify_new_connections": "True", # Enables role-verification for new endpoints
72+
"wrapper_dialect": "aurora-mysql",
73+
"autocommit": True,
74+
}
75+
76+
""" Setup step: open connection and create tables """
77+
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
78+
configure_initial_session_states(conn)
79+
execute_queries_with_failover_handling(
80+
conn,
81+
"CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)",
82+
)
83+
execute_queries_with_failover_handling(
84+
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200)
85+
)
86+
execute_queries_with_failover_handling(
87+
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200)
88+
)
89+
90+
""" Example step: open connection and perform transaction """
91+
try:
92+
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn, conn.cursor() as cursor:
93+
configure_initial_session_states(conn)
94+
95+
execute_queries_with_failover_handling(
96+
conn,
97+
"UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s",
98+
("Jane Doe",),
99+
)
100+
execute_queries_with_failover_handling(
101+
conn,
102+
"UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s",
103+
("John Smith",),
104+
)
105+
106+
# Internally switch to a reader connection
107+
conn.read_only = True
108+
for i in range(2):
109+
cursor = execute_queries_with_failover_handling(
110+
conn, "SELECT * FROM bank_test WHERE id = %s", (i,)
111+
)
112+
for record in cursor:
113+
print(record)
114+
115+
finally:
116+
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
117+
execute_queries_with_failover_handling(conn, "DROP TABLE bank_test")

docs/examples/PGFailover.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
4343

4444
except FailoverSuccessError:
4545
# Query execution failed and AWS Advanced Python Driver successfully failed over to an available instance.
46-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---successful-failover
46+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoversuccesserror
4747

4848
# The old cursor is no longer reusable and the application needs to reconfigure sessions states.
4949
configure_initial_session_states(conn)
@@ -54,12 +54,12 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
5454

5555
except FailoverFailedError as e:
5656
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
57-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#FailoverFailedError---unable-to-establish-sql-connection
57+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
5858
raise e
5959

6060
except TransactionResolutionUnknownError as e:
6161
# User application should check the status of the failed transaction and restart it if needed. See:
62-
# https://github.com/awslabs/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#TransactionResolutionUnknownError---transaction-resolution-unknown
62+
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror
6363
raise e
6464

6565

0 commit comments

Comments
 (0)