18
18
Protocol , Tuple , runtime_checkable )
19
19
20
20
from aws_advanced_python_wrapper .driver_info import DriverInfo
21
+ from aws_advanced_python_wrapper .utils .rds_url_type import RdsUrlType
21
22
22
23
if TYPE_CHECKING :
23
24
from aws_advanced_python_wrapper .pep249 import Connection
@@ -98,6 +99,15 @@ def is_reader_query(self) -> str:
98
99
return self ._IS_READER_QUERY
99
100
100
101
102
+ @runtime_checkable
103
+ class AuroraLimitlessDialect (Protocol ):
104
+ _LIMITLESS_ROUTER_ENDPOINT_QUERY : str
105
+
106
+ @property
107
+ def limitless_router_endpoint_query (self ) -> str :
108
+ return self ._LIMITLESS_ROUTER_ENDPOINT_QUERY
109
+
110
+
101
111
class DatabaseDialect (Protocol ):
102
112
"""
103
113
Database dialects help the AWS Advanced Python Driver determine what kind of underlying database is being used,
@@ -342,7 +352,7 @@ def get_host_list_provider_supplier(self) -> Callable:
342
352
return lambda provider_service , props : RdsHostListProvider (provider_service , props )
343
353
344
354
345
- class AuroraPgDialect (PgDatabaseDialect , TopologyAwareDatabaseDialect ):
355
+ class AuroraPgDialect (PgDatabaseDialect , TopologyAwareDatabaseDialect , AuroraLimitlessDialect ):
346
356
_DIALECT_UPDATE_CANDIDATES : Tuple [DialectCode , ...] = (DialectCode .MULTI_AZ_PG ,)
347
357
348
358
_EXTENSIONS_QUERY = "SELECT (setting LIKE '%aurora_stat_utils%') AS aurora_stat_utils " \
@@ -359,6 +369,7 @@ class AuroraPgDialect(PgDatabaseDialect, TopologyAwareDatabaseDialect):
359
369
360
370
_HOST_ID_QUERY = "SELECT aurora_db_instance_identifier()"
361
371
_IS_READER_QUERY = "SELECT pg_is_in_recovery()"
372
+ _LIMITLESS_ROUTER_ENDPOINT_QUERY = "SELECT router_endpoint, load FROM aurora_limitless_router_endpoints()"
362
373
363
374
@property
364
375
def dialect_update_candidates (self ) -> Optional [Tuple [DialectCode , ...]]:
@@ -621,6 +632,11 @@ def get_dialect(self, driver_dialect: str, props: Properties) -> DatabaseDialect
621
632
622
633
if target_driver_type is TargetDriverType .POSTGRES :
623
634
rds_type = self ._rds_helper .identify_rds_type (host )
635
+ if rds_type == RdsUrlType .RDS_AURORA_LIMITLESS_DB_SHARD_GROUP :
636
+ self ._can_update = False
637
+ self ._dialect_code = DialectCode .AURORA_PG
638
+ self ._dialect = DatabaseDialectManager ._known_dialects_by_code [DialectCode .AURORA_PG ]
639
+ return self ._dialect
624
640
if rds_type .is_rds_cluster :
625
641
self ._can_update = True
626
642
self ._dialect_code = DialectCode .AURORA_PG
0 commit comments