How to bind a redshift jdbc to sqlalchemy engine to create session

113 views Asked by At

I am accessing a redshift database through IAM role via AWS, i am using AzureCredentialProvider.
i am able to get connection via JDBC connection in python.

driver = "com.amazon.redshift.jdbc.Driver"
connection_str = jdbc:redshift://cluster.xxidxx.region.redshift.amazonaws.com:5439/db;plugin_name=com.amazon.redshift.com.AzureCredentialProvider;client_id=foo;client_secret=bar;idp_tenant=idp;ClusterId=cluster;dbgroups=dbgroups;Region=region;IAMuth=true
jdbc_jar_files = os.path.join(r'path/redshift-jdbc42-2.1.0.13.jar')

I am making connection as follows:

connection = jaydebeapi.connect(driver, connection_str, {'user': username, 'password': password}, jars=jdbc_jar_files)

I am able to make a connection with details. But I want to create a engine or sessionmaker object to bind it with Sqlalchemy ORM.

I don't able to come up with how to do that.

I have tried using sqlalchemy-redshift and redshiftconnector , but of no luck, as they are asking access key and secret key which I do not have.

I want to either create an sqlalchemy engine with connection or get the right url to make sqlalchemy engine to make sessions and to use orm.

Is there any way to do that.

I also have role in format of arn:aws:iam::{id}:role/{role} , if it helps.

0

There are 0 answers