Registry / aws / sqlalchemy-rdsiam

sqlalchemy-rdsiam

JSON →
library1.0.3pypypi✓ verified 84d ago

SQLAlchemy dialects for connecting to Amazon RDS instances using IAM database authentication. Requires boto3 and SQLAlchemy. Version 1.0.3 (latest), maintains compatibility with Python 3.6+. Low release cadence, currently maintained by Cisco.

pip install sqlalchemy-rdsiam
INSTALL
IMPORT
SIG · SQLALCHEMY-RDSIAM
S
sqlalchemy-rdsiam
awspythonv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_engine
from sqlalchemy import create_engine
from sqlalchemy_rdsiam import create_engine
create_engine is from SQLAlchemy core, not this library.

Connect to RDS PostgreSQL with IAM auth using the 'postgresql+iam' dialect.

import os from sqlalchemy import create_engine engine = create_engine( "postgresql+iam://dbuser@host:5432/mydb", connect_args={ "aws_access_key_id": os.environ.get('AWS_ACCESS_KEY_ID',''), "aws_secret_access_key": os.environ.get('AWS_SECRET_ACCESS_KEY',''), "region": "us-east-1" } ) # Example query with engine.connect() as conn: result = conn.execute("SELECT 1") print(result.fetchone())
Debug
Known issues
breakingThe 'postgresql+iam' dialect does not support SSL certificate verification by default; ensure your RDS instance enforces IAM auth with SSL.
fix
Add sslmode='require' to connection parameters or use sslrootcert.
affects: all
gotchaThe dialect only supports PostgreSQL and MySQL. Using it with other databases raises NotImplementedError.
fix
Verify your database is PostgreSQL or MySQL.
affects: >=1.0.1
gotchaIAM tokens expire after 15 minutes; the library does NOT automatically refresh. Long-lived connections must handle token renewal.
fix
Use a custom connection pool or recreate engine periodically.
affects: all
Errors
Common errors & fixes
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgresql.iam
The 'postgresql+iam' dialect is not registered because sqlalchemy-rdsiam is not installed or imported.
fix
Install the library: pip install sqlalchemy-rdsiam
NotImplementedError: flavour not supported
Using an unsupported database type (e.g., mysql+iam instead of mysql, or oracle+iam).
fix
Use one of: 'postgresql+iam' or 'mysql+iam'.
boto3.exceptions.NoCredentialsError: Unable to locate credentials
AWS credentials not provided or not configured in environment.
fix
Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables, or pass them in connect_args.
Upgrade
Version history
1.0.3latest on PyPI · released Nov 8, 2023
Audit
Dependencies
sqlalchemyrequiredCore dependency (>=1.3)
boto3requiredAWS SDK for IAM authentication
psycopg2-binaryoptionalPostgreSQL driver (if using postgresql+iam)
pymysqloptionalMySQL driver (if using mysql+iam)
Agent activity
32 hits · last 30 days
node
28
Meta
1
OpenAI (training)
1
Resources
sqlalchemy-rdsiam — pip install sqlalchemy-rdsiam · libregistry