Skip to content

rds run-sql

Run SQL Query

Description

run sql query in aws rds mysql instance

Synopsis

rds run-sql
    [--site <site>]
    [--region <region>]
    [--host <host>]
    [--database <database>]
    <query>

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

region - (string)

     AWS region for the service
     Example: --region "region-1"
     Default: _None_      Attributes: optional

host - (string)

     Host name for database instance
     Example: --host "host-1"
     Default: _None_      Attributes: optional

database - (string)

     Database name
     Example: --database "database-1"
     Default: _None_      Attributes: optional

query - (string)

     Sql Query
     Example: "select * from accounts"
     Default: _None_      Attributes: required

Examples

Input:

x=! rds run-sql --host "host1" "create database testdb"
Output:

Input:
x=! rds run-sql --host "host1" "select * from movies.movies"
Output:
[                                                                                                                                                                  
  {
    "director": "Todd Phillips",
    "genre": "psychological thriller",
    "release_year": 2019,
    "title": "Joker"
  },
  {
    "director": "Karan Johar",
    "genre": "psychological thriller",
    "release_year": 2020,
    "title": "Movie1"
  }
]
Input:
! rds run-sql --host "host1" "select * from movies.movies"
Output:
title   director        genre                   release_year    
Joker   Todd Phillips   psychological thriller          2019
Movie1  Karan Johar     psychological thriller          2020 

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "rds"
Service Instance
Namespace
Object Type "query"
Object ID

Please see Access Control for details.