Skip to content
Merged
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
2 changes: 1 addition & 1 deletion 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 # type: ignore
import mysql.connector # type: ignore

from aws_advanced_python_wrapper import AwsWrapperConnection
from aws_advanced_python_wrapper.connection_provider import \
Expand Down
15 changes: 8 additions & 7 deletions docs/examples/MySQLSimpleReadWriteSplitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@

from __future__ import annotations

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

if TYPE_CHECKING:
from aws_advanced_python_wrapper.pep249 import Connection

import mysql.connector # type: ignore
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'")
Expand Down Expand Up @@ -60,15 +61,15 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O


if __name__ == "__main__":
params = {
params: Any = {
"host": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
"database": "mysql",
"user": "admin",
"password": "pwd",
"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
"srw_write_endpoint": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
"srw_read_endpoint": "rds-proxy-name-read-only.endpoint.proxy-xyz.us-east-1.rds.amazonaws.com",
"srw_verify_new_connections": "True",
"wrapper_dialect": "aurora-mysql",
"autocommit": True,
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/PGReadWriteSplitting.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 psycopg # type: ignore
import psycopg # type: ignore

from aws_advanced_python_wrapper import AwsWrapperConnection
from aws_advanced_python_wrapper.connection_provider import \
Expand Down
14 changes: 7 additions & 7 deletions docs/examples/PGSimpleReadWriteSplitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

from __future__ import annotations

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

if TYPE_CHECKING:
from aws_advanced_python_wrapper.pep249 import Connection

import psycopg # type: ignore
import psycopg # type: ignore

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


def configure_initial_session_states(conn: Connection):
awscursor = conn.cursor()
Expand Down Expand Up @@ -61,15 +61,15 @@ def execute_queries_with_failover_handling(conn: Connection, sql: str, params: O


if __name__ == "__main__":
params = {
params: Any = {
"host": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
"dbname": "postgres",
"user": "john",
"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
"srw_write_endpoint": "rds-proxy-name.proxy-xyz.us-east-1.rds.amazonaws.com",
"srw_read_endpoint": "rds-proxy-name-read-only.endpoint.proxy-xyz.us-east-1.rds.amazonaws.com",
"srw_verify_new_connections": "True",
"wrapper_dialect": "aurora-pg",
"autocommit": True,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ When connecting with custom endpoints and other non-standard URLs, role verifica
## Limitations When Verifying Connections

#### Non-RDS clusters
The verification step determines the role of the connection by executing a query against it. If the endpoint is not part of an Aurora or RDS cluster, the plugin will not be able to verify the role, so `srw_verify_new_connections` *must* be set to `False`.
The verification step determines the role of the connection by executing a query against it. The AWS Advanced Python Driver does not support gathering such information for databases that are not Aurora or RDS clusters. Thus, when connecting to non-RDS clusters `verifyNewSrwConnections` must be set to `false`.

#### Autocommit
The verification logic results in errors such as `Cannot change transaction read-only property in the middle of a transaction` from the underlying driver when:
Expand Down