Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Maintenance.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Release Schedule

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

`aws-advanced-python-wrapper` [follows semver](https://semver.org/#semantic-versioning-200) which means we will only
release breaking changes in major versions. Generally speaking patches will be released to fix existing problems without
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Enhanced Failure Monitoring (EFM) is a feature available from the [Host Monitori

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

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

## Getting Started

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

If you encounter a bug with the AWS Advanced Python Driver, we would like to hear about it.
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.
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.

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

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

## How to Contribute

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The benchmarks do not measure the performance of target Python drivers nor the p

## Benchmark Results

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

## Summary
| Benchmark | Overhead |
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Federated Authentication Plugin](./using-the-python-driver/using-plugins/UsingTheFederatedAuthenticationPlugin.md)
- [Read Write Splitting Plugin](./using-the-python-driver/using-plugins/UsingTheReadWriteSplittingPlugin.md)
- [Reader Selection Strategies](./using-the-python-driver/ReaderSelectionStrategies.md)
- [Simple Read Write Splitting Plugin](./using-the-python-driver/using-plugins/UsingTheSimpleReadWriteSplittingPlugin.md)
- [Fastest Response Strategy Plugin](./using-the-python-driver/using-plugins/UsingTheFastestResponseStrategyPlugin.md)
- [Host Availability Strategy](./using-the-python-driver/HostAvailabilityStrategy.md)
- [Development Guide](./development-guide/DevelopmentGuide.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/development-guide/DevelopmentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Make sure you have Python 3.8 - 3.11 (inclusive) installed, along with your choi
Clone the AWS Advanced Python Driver repository:

```bash
git clone https://github.com/awslabs/aws-advanced-python-wrapper.git
git clone https://github.com/aws/aws-advanced-python-wrapper.git
```

You can now make changes in the repository.
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/MySQLFailover.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O

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

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

except FailoverFailedError as e:
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
# 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
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
raise e

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


Expand Down
34 changes: 23 additions & 11 deletions docs/examples/MySQLReadWriteSplitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from aws_advanced_python_wrapper.hostinfo import HostInfo
from aws_advanced_python_wrapper.pep249 import Connection

import mysql.connector
import mysql.connector # type: ignore

from aws_advanced_python_wrapper import AwsWrapperConnection
from aws_advanced_python_wrapper.connection_provider import \
Expand Down Expand Up @@ -58,7 +58,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O

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

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

except FailoverFailedError as e:
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
# 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
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
raise e

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


Expand All @@ -86,7 +86,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
"password": "pwd",
"plugins": "read_write_splitting,failover",
"wrapper_dialect": "aurora-mysql",
"autocommit": True
"autocommit": True,
}

"""
Expand All @@ -101,26 +101,38 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
configure_initial_session_states(conn)
execute_queries_with_failover_handling(
conn, "CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)")
conn,
"CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)",
)
execute_queries_with_failover_handling(
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200))
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200)
)
execute_queries_with_failover_handling(
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200))
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200)
)

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

execute_queries_with_failover_handling(
conn, "UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s", ("Jane Doe",))
conn,
"UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s",
("Jane Doe",),
)
execute_queries_with_failover_handling(
conn, "UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s", ("John Smith",))
conn,
"UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s",
("John Smith",),
)

# Internally switch to a reader connection
conn.read_only = True
for i in range(2):
cursor = execute_queries_with_failover_handling(conn, "SELECT * FROM bank_test WHERE id = %s", (i,))
cursor = execute_queries_with_failover_handling(
conn, "SELECT * FROM bank_test WHERE id = %s", (i,)
)
for record in cursor:
print(record)

Expand Down
117 changes: 117 additions & 0 deletions docs/examples/MySQLSimpleReadWriteSplitting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union

if TYPE_CHECKING:
from aws_advanced_python_wrapper.pep249 import Connection

import mysql.connector # type: ignore

from aws_advanced_python_wrapper import AwsWrapperConnection
from aws_advanced_python_wrapper.errors import (
FailoverFailedError, FailoverSuccessError,
TransactionResolutionUnknownError)

def configure_initial_session_states(conn: Connection):
awscursor = conn.cursor()
awscursor.execute("SET time_zone = 'UTC'")


def execute_queries_with_failover_handling(conn: Connection, sql: str, params: Optional[Union[Dict, Tuple]] = None):
try:
cursor = conn.cursor()
cursor.execute(sql, params)
return cursor

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

# The old cursor is no longer reusable and the application needs to reconfigure sessions states.
configure_initial_session_states(conn)
# Retry query
cursor = conn.cursor()
cursor.execute(sql)
return cursor

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

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


if __name__ == "__main__":
params = {
"host": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
"database": "mysql",
"user": "admin",
"password": "pwd",
"plugins": "srw,failover",
"srw_write_endpoint": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com", # Replace with write endpoint
"srw_read_endpoint": "rds-proxy-name-read-only.endpoint.proxy-xyz.us-east-1.rds.amazonaws.com", # Replace with read endpoint
"srw_verify_new_connections": "True", # Enables role-verification for new endpoints
"wrapper_dialect": "aurora-mysql",
"autocommit": True,
}

""" Setup step: open connection and create tables """
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
configure_initial_session_states(conn)
execute_queries_with_failover_handling(
conn,
"CREATE TABLE IF NOT EXISTS bank_test (id int primary key, name varchar(40), account_balance int)",
)
execute_queries_with_failover_handling(
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (0, "Jane Doe", 200)
)
execute_queries_with_failover_handling(
conn, "INSERT INTO bank_test VALUES (%s, %s, %s)", (1, "John Smith", 200)
)

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

execute_queries_with_failover_handling(
conn,
"UPDATE bank_test SET account_balance=account_balance - 100 WHERE name=%s",
("Jane Doe",),
)
execute_queries_with_failover_handling(
conn,
"UPDATE bank_test SET account_balance=account_balance + 100 WHERE name=%s",
("John Smith",),
)

# Internally switch to a reader connection
conn.read_only = True
for i in range(2):
cursor = execute_queries_with_failover_handling(
conn, "SELECT * FROM bank_test WHERE id = %s", (i,)
)
for record in cursor:
print(record)

finally:
with AwsWrapperConnection.connect(mysql.connector.Connect, **params) as conn:
execute_queries_with_failover_handling(conn, "DROP TABLE bank_test")
6 changes: 3 additions & 3 deletions docs/examples/PGFailover.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O

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

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

except FailoverFailedError as e:
# User application should open a new connection, check the results of the failed transaction and re-run it if needed. See:
# 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
# https://github.com/aws/aws-advanced-python-wrapper/blob/main/docs/using-the-python-driver/using-plugins/UsingTheFailoverPlugin.md#failoverfailederror
raise e

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


Expand Down
Loading