- Newest
- Most votes
- Most comments
Hiya ,
it's likely that there's a problem with the way that psycopg2 is handling IAM authentication.
One possible solution is to use the connection_factory parameter to the psycopg2.connect() function. This parameter allows you to specify a custom connection factory that will be used to create the connection. You can use this to create a connection factory that uses IAM authentication.
Here's an example of how to do this:
Python import psycopg2
def my_connection_factory(dbname, user, password, host, port): connection = psycopg2.connect( dbname=dbname, user=user, password=password, host=host, port=port, connection_factory=psycopg2.extras.LogicalReplicationConnection, ) return connection
conn = psycopg2.connect( dbname="mydb", user="replicate", password="mypassword", host="myhost", port="5432", connection_factory=my_connection_factory, ) Use code with caution. Learn more This code will create a connection to the database using IAM authentication. If the password is correct, then the connection should be successful.
Relevant content
- asked 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago