Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mobilequickie/8638752df2149bed5496ae000fbab558 to your computer and use it in GitHub Desktop.
Save mobilequickie/8638752df2149bed5496ae000fbab558 to your computer and use it in GitHub Desktop.
Executing a select * statement against an Aurora Serverless Data API enabled database using the "rds-data" API from the AWS CLI
//Select * query from Aurora Serverless (w/ Data API enabled) using the "execute-sql" API
aws rds-data execute-sql --db-cluster-or-instance-arn "arn:aws:rds:us-east-1:xxxxxxxxxxxx:cluster:my-serverless-cluster" --schema "" \
--database "MarketPlace" --aws-secret-store-arn "arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:RDSAuroraServerlessMasterSecret-3haLhV" \
--sql-statements "select * from Customers" --region us-east-1 \
--endpoint-url https://rds-data.us-east-1.amazonaws.com
@mobilequickie
Copy link
Author

mobilequickie commented Apr 23, 2019

// Sample result for 2 rows returned from above sql select statement via the AWS CLI using --> aws rds-data execute-sql

{
    "sqlStatementResults": [
        {
            "numberOfRecordsUpdated": -1,
            "resultFrame": {
                "records": [
                    {
                        "values": [
                            {
                                "intValue": 1
                            },
                            {
                                "stringValue": "Customer One"
                            },
                            {
                                "stringValue": "111-222-3333"
                            },
                            {
                                "stringValue": "customer1@mydomain.com"
                            }
                        ]
                    },
                    {
                        "values": [
                            {
                                "intValue": 2
                            },
                            {
                                "stringValue": "Customer Two"
                            },
                            {
                                "stringValue": "206-xxx-yyyy"
                            },
                            {
                                "stringValue": "cust@customer2.com"
                            }
                        ]
                    }
                ],
                "resultSetMetadata": {
                    "columnCount": 4,
                    "columnMetadata": [
                        {
                            "arrayBaseColumnType": 0,
                            "isAutoIncrement": false,
                            "isCaseSensitive": false,
                            "isCurrency": false,
                            "isSigned": true,
                            "label": "id",
                            "name": "id",
                            "nullable": 0,
                            "precision": 11,
                            "scale": 0,
                            "schemaName": "",
                            "tableName": "Customers",
                            "type": 4,
                            "typeName": "INT"
                        },
                        {
                            "arrayBaseColumnType": 0,
                            "isAutoIncrement": false,
                            "isCaseSensitive": false,
                            "isCurrency": false,
                            "isSigned": false,
                            "label": "name",
                            "name": "name",
                            "nullable": 0,
                            "precision": 50,
                            "scale": 0,
                            "schemaName": "",
                            "tableName": "Customers",
                            "type": 12,
                            "typeName": "VARCHAR"
                        },
                        {
                            "arrayBaseColumnType": 0,
                            "isAutoIncrement": false,
                            "isCaseSensitive": false,
                            "isCurrency": false,
                            "isSigned": false,
                            "label": "phone",
                            "name": "phone",
                            "nullable": 0,
                            "precision": 50,
                            "scale": 0,
                            "schemaName": "",
                            "tableName": "Customers",
                            "type": 12,
                            "typeName": "VARCHAR"
                        },
                        {
                            "arrayBaseColumnType": 0,
                            "isAutoIncrement": false,
                            "isCaseSensitive": false,
                            "isCurrency": false,
                            "isSigned": false,
                            "label": "email",
                            "name": "email",
                            "nullable": 0,
                            "precision": 50,
                            "scale": 0,
                            "schemaName": "",
                            "tableName": "Customers",
                            "type": 12,
                            "typeName": "VARCHAR"
                        }
                    ]
                }
            }
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment