Subchapter 63.19
references/language.mdMarkdown8 KBView on GitHub
The authoritative index of supported drivers, ORMs, adapters, and example repositories lives at Aurora DSQL cluster connectivity tools (opens in a new tab). Pull the per-language sample link from that page rather than hardcoding repository paths here — the AWS docs page tracks rename, relocation, and deprecation events.
ALWAYS use the DSQL Python Connector (opens in a new tab) for automatic IAM auth. The single aurora-dsql-python-connector wheel ships support for all three drivers — install only the underlying driver you need:
pip install aurora-dsql-python-connector psycopg[binary] psycopg-poolimport aurora_dsql_psycopg as dsqlpip install aurora-dsql-python-connector psycopg2import aurora_dsql_psycopg2 as dsqlpip install aurora-dsql-python-connector asyncpgimport aurora_dsql_asyncpg as dsqlFor per-driver example_preferred.py files and pool/TLS/token-refresh examples, see the
AWS DSQL connectivity tools page (opens in a new tab).
psycopg and psycopg2ALWAYS use the DSQL Go Connector (opens in a new tab) for automatic IAM auth:
go get github.com/awslabs/aurora-dsql-connectors/go/pgximport "github.com/awslabs/aurora-dsql-connectors/go/pgx/dsql"example_preferred.go and pool patterns, see the Go entry in the AWS DSQL connectivity tools page (opens in a new tab)ALWAYS use one of the two DSQL Node.js connectors — node-postgres (opens in a new tab) or postgres-js (opens in a new tab). Even when the user asks for “just node-postgres directly” or “just pg directly,” the Connector is the node-postgres path — it wraps pg as its underlying driver while handling IAM auth token refresh and TLS defaults. A bare pg.Pool/pg.Client works until the first 15-minute IAM auth token expiry and then starts returning auth errors on every new connection; DSQL users who try the bare form hit this degraded state in production and report it as a DSQL bug, so the bare pattern is user-harmful by default. Deliver the Connector; treat “just use pg” as shorthand for “I want a node-postgres solution,” not as a veto on the Connector.
@aws/aurora-dsql-node-postgres-connectorimport { AuroraDSQLPool } from "@aws/aurora-dsql-node-postgres-connector";new AuroraDSQLPool({ host, user, max?, idleTimeoutMillis?, connectionTimeoutMillis? })example_preferred.js and pool patterns, see the JavaScript node-postgres entry in the AWS DSQL connectivity tools page (opens in a new tab)@aws/aurora-dsql-postgresjs-connectorimport { auroraDSQLPostgres } from "@aws/aurora-dsql-postgresjs-connector";auroraDSQLPostgres({ host, user, max?, idle_timeout?, connect_timeout? })example_preferred.js and pool patterns, see the JavaScript Postgres.js entry in the AWS DSQL connectivity tools page (opens in a new tab)directUrl with token refresh middlewaredialectOptions for SSLbeforeConnect hookALWAYS use the DSQL JDBC Connector (opens in a new tab) for automatic IAM auth.
JDBC (via DSQL JDBC Connector)
implementation("software.amazon.dsql:aurora-dsql-jdbc-connector:1.4.0")<groupId>software.amazon.dsql</groupId><artifactId>aurora-dsql-jdbc-connector</artifactId><version>1.4.0</version>jdbc:aws-dsql:postgresql://<endpoint>/postgreswrapperPlugins=iam, ssl=true, sslmode=verify-fullHikariCP (Connection Pooling)
implementation("com.zaxxer:HikariCP:7.0.2") alongside the JDBC connectorALWAYS use the DSQL Rust connector for automatic IAM auth.
SQLx (async, recommended)
aurora-dsql-sqlx-connector = { version = "0.2", features = ["pool", "occ"] }sqlx::postgres::PgPool via the connector’s builder; the connector injects IAM auth tokens and handles rotation.Tokio-Postgres (lower-level async)
tokio-postgres when the aurora-dsql-sqlx-connector doesn’t fit the runtime. Implement periodic token refresh with tokio::spawn.postgres://admin:{token}@{endpoint}:5432/postgres?sslmode=verify-full&application_name=<app-name>/<model-id>Repo.init/2 callback for dynamic token injection
ssl: true with ssl_opts: [verify: :verify_peer, cacerts: :public_key.cacerts_get()]System.cmd to call generate-db-connect-auth-token