Skip to main content

Custom Connection Factory class (RDS, Redshift) with build-in IAM authentication and SSL bundle downloader support.

Project description

psycopg2-iam

Custom Connection Factory class (RDS, Redshift) with build-in IAM authentication and SSL bundle downloader support.

Installation

Install package

poetry add psycopg2-iam

Usage

Create connection directly from secret

from psycopg2_iam import connect

conn = connect(secret="secretId")

Using connect function

from psycopg2_iam import connect
connect(dsn="...")

Pass connection factory class to psycopg2.connect()

import psycopg2 
from psycopg2_iam import IAMConnection

psycopg2.connect(dsn="...", connection_factory=IAMConnection)

Create DSN from AWS generated RDS secret

import boto3
import json
import psycopg2 
from psycopg2_iam import IAMConnection, dsn_from_rds_secret

secrets = boto3.client("secretsmanager")
db_secret = json.loads(secrets.get_secret_value(SecretId="/dynks/rds/readonly").get("SecretString"))

psycopg2.connect(dsn=dsn_from_rds_secret(db_secret), connection_factory=IAMConnection)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psycopg2-iam-1.1.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

psycopg2_iam-1.1.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page