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())
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.
fixInstall 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).
fixUse one of: 'postgresql+iam' or 'mysql+iam'.
boto3.exceptions.NoCredentialsError: Unable to locate credentials
AWS credentials not provided or not configured in environment.
fixSet 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)