Writing rows with PutRows
You can write rows by using the AWS CLI, the AWS SDKs, or the S3 Tables API. The following procedures write rows to a table with the AWS CLI and with the AWS SDK for Python (Boto3). To use these examples, replace the placeholders with your own information.
The example uses a table with the columns event_id string, event_type string, user_id string, event_time timestamptz, and amount double.
To write rows by using the AWS CLI
-
Save the following as
rows.ndjson. Send one JSON object per row, separated by newlines. Don't wrap the rows in a JSON array.{"event_id": "e-001", "event_type": "page_view", "user_id": "u-123", "event_time": "2026-11-02T10:00:00Z", "amount": 0.0} {"event_id": "e-002", "event_type": "purchase", "user_id": "u-456", "event_time": "2026-11-02T10:00:01Z", "amount": 42.5} -
Then write the rows.
aws s3tables put-rows \ --regionus-east-1\ --table-arn $TABLE_ARN \ --payload-format JSON \ --payload fileb://rows.ndjsonA successful response returns the number of rows accepted.
{ "acceptedRows": 2 } -
Check the table's channel. The default channel is created by the first PutRows request.
aws s3tables get-channel \ --regionus-east-1\ --table-arn $TABLE_ARN{ "state": "active", "approximateNumberOfBufferedRows": 0 }The buffered row count is approximate and can read
0before your rows are committed. To confirm the commit, query the table. -
Query the table with any engine that reads S3 Tables. For example, in Amazon Athena with the S3 Tables catalog integration:
SELECT * FROM "s3tablescatalog/amzn-s3-demo-table-bucket"."example_namespace"."example_events";
The query returns the rows that you wrote.
To write rows by using the AWS SDK for Python (Boto3)
The following example writes the same two rows with the AWS SDK for Python (Boto3), and then checks the table's channel. To use this example, replace the placeholders with your own information.
import json import boto3 TABLE_ARN = "arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-table-bucket/table/table-id" client = boto3.client("s3tables", region_name="us-east-1") rows = [ {"event_id": "e-001", "event_type": "page_view", "user_id": "u-123", "event_time": "2026-11-02T10:00:00Z", "amount": 0.0}, {"event_id": "e-002", "event_type": "purchase", "user_id": "u-456", "event_time": "2026-11-02T10:00:01Z", "amount": 42.5}, ] # Send one JSON object per row, separated by newlines (NDJSON). payload = "\n".join(json.dumps(row, separators=(",", ":")) for row in rows).encode("utf-8") response = client.put_rows( tableARN=TABLE_ARN, payloadFormat="JSON", payload=payload, ) print(f"Accepted rows: {response['acceptedRows']}") channel = client.get_channel(tableARN=TABLE_ARN) print(f"Channel state: {channel['state']}")
The SDK computes the payload checksum, signs the request, and retries 429, 500, and 503 errors automatically. To confirm that the rows are committed, query the table as shown in the previous procedure.