You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's an issue with awswrangler when attempting to insert UUID values into a PostgreSQL table’s UUID column using the to_sql method with the AWS Data API.
:ERROR: column "id" is of type uuid but expression is of type text
:HINT: You will need to rewrite or cast the expression.
How to Reproduce
CREATETABLEusers (
id UUID PRIMARY KEY,
name VARCHAR(50)
);
importawswrangleraswrimportpandasaspdimportuuid# Number of records to insertnum_records=10# Generate a list of random UUIDs for the 'id' columnid_list= [uuid.uuid4() for_inrange(num_records)]
# Sample DataFrame with random UUIDs for 'id' and namesdf=pd.DataFrame({
'id': id_list, # Generated UUIDs'name': [f'User{i}'foriinrange(1, num_records+1)] # Generate names as User1, User2, etc.
})
# AWS RDS connection parametersdb_cluster_arn="your-cluster-arn"db_credentials_secrets_store_arn="your-secret-arn"database="your-database-name"table_name="users"conn=wr.data_api.rds.connect(
resource_arn=db_cluster_arn,
database=database,
secret_arn=db_credentials_secrets_store_arn,
)
# Attempt to insert data into a PostgreSQL table with a UUID column using awswranglertry:
wr.data_api.rds.to_sql(
df=df,
conn=conn,
table=table_name,
database=database,
use_column_names=True,
mode="append",
sql_mode="ansi",
index=False
)
exceptExceptionase:
print("An error occurred:", e)
Expected behavior
No response
Your project
No response
Screenshots
No response
OS
Mac
Python version
3.11.6
AWS SDK for pandas version
3.9.1
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
There's an issue with awswrangler when attempting to insert UUID values into a PostgreSQL table’s UUID column using the to_sql method with the AWS Data API.
How to Reproduce
Expected behavior
No response
Your project
No response
Screenshots
No response
OS
Mac
Python version
3.11.6
AWS SDK for pandas version
3.9.1
Additional context
No response
The text was updated successfully, but these errors were encountered: