sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Creating a connection pool with custom connector

Open SebastienMelki opened this issue 1 year ago • 2 comments

Hello,

We are using IAM Authentication in order to connect to an RDS mysql cluster. We are encountering a problem: the credentials that the connection pool is using have to be modified every 15 minutes, because AWS only provide tokens with a TTL of 15 minutes.

A solution to use IAM with connection pooling and the mysql driver is described here https://github.com/go-sql-driver/mysql/issues/1354 but it involves using a custom connector. It seems to be using sql.OpenDB() instead of sql.Open().

Is there a way to use a custom connector with sqlx? I couldn't find a way to plug it in.

If not, is there a recommended way to use sqlx mysql connection pools with aws IAM?

Thank you

SebastienMelki avatar Jun 10 '24 10:06 SebastienMelki

By the looks of it, you can (probably) get what you need by creating your driver.Connector, passing that to sql.OpenDB(), and then passing the resulting sql.DB to sqlx.NewDB().

mpalmer avatar Oct 26 '24 23:10 mpalmer

it was NewDb, thanks

phanirithvij avatar Jan 27 '25 13:01 phanirithvij