aws-sdk-pandas icon indicating copy to clipboard operation
aws-sdk-pandas copied to clipboard

Is it possible to specify a schema name when using `wr.data_api.rds` module

Open francisco-parrilla-lner opened this issue 6 months ago • 2 comments

Hi,

Is it possible to specify a schema when trying to write data to an rds postgres database?

During creation of the connection, for example:

rds_connection = wr.data_api.rds.RdsDataApi(
        resource_arn="arn:aws:rds:eu-west-2:XXXXXX:cluster:XXXXXX",
        secret_arn="XXXXXXX",
        database="my-db",
    )

Is not possible to specify a schema, other than using the public one which comes by default. I have another schema with other tables.

When trying to write using:

wr.data_api.rds.to_sql(
            df=df,
            con=rds_connection,
            table=table_name,
            database=db_name,
            mode=mode,
            index=False,
            dtype=schema_overrides,
            sql_mode="ansi",
            use_column_names=True,
        )

Is not possible either to specify the schema name, if I try to use the schema name and pass it to database I get an error, so that should match the value in the rds_connection creation.

When looking at awswrangler.data_api.rds.py module, I can see in the to_sql function that when creating a transaction (line 449), before proceeding with the write to the rds, .begin_transaction() also accepts schema parameter:

 transaction_id = con.begin_transaction(database=database) # this also accepts `schema`

How can I specify the schema when calling .to_sql() call?

P.S. Please do not attach files as it's considered a security risk. Add code snippets directly in the message body as much as possible.

francisco-parrilla-lner avatar May 27 '25 16:05 francisco-parrilla-lner

Hi @francisco-parrilla-lner thanks for opening this! We do not have the parameter, but it is definitely possible. We'll work on that.

kukushking avatar Jun 13 '25 12:06 kukushking

Not sure if it possible to be honest. I modified locally the awswrangler code, and I got a botocore exceptions. And I tried to use the boto3 rds data api client directly, and I also got the same botocore exception. It seems even though this is available as a parameter in boto3 client, you can't use it.

Is it possible for you to try on your end? If this is not possible because of botocore, please let me know and feel free to close this issue.

francisco-parrilla-lner avatar Jun 13 '25 13:06 francisco-parrilla-lner

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 7 days it will automatically be closed.

github-actions[bot] avatar Aug 12 '25 18:08 github-actions[bot]