MySqlSelect
Execute a MySQL SELECT Statement.
Added in version 1.0.0.
Friendly name:
MySQL SelectStep class:
base_steps_syncpack.steps.MySqlSelect.MySqlSelectStep version:
1.1.3Required parameters:
database,host,username,password,port
Parameters
Name |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
no |
– |
The database Table Example: |
|
string |
yes |
– |
The database Example: |
|
string |
yes |
– |
The host of the database Example: |
|
string |
yes |
– |
The db username Example: |
|
string |
yes |
– |
The db password Example: |
|
string (long) |
no |
– |
A full SELECT statement. Overrides the ‘fields’ statement. Example: |
|
array of strings |
no |
|
Which fields to select. Example: |
|
number |
yes |
|
The port number to use when establishing a connection to the remote mysql server. |
Every step also accepts the platform parameters common to all steps – see Platform parameters.
Dependencies
Inherits from:
MySqlSelect->BaseStep->SerializableSyncPack modules:
base_steps_syncpack.utilExternal packages:
ipaascommon,ipaascore
Behaviour
Connects through util.mysql_utils.util_connect_mysql (pymysql,
DictCursor) and runs a SELECT. The query is resolved in this order:
select_query, used verbatim;SELECT * FROM {table}whenfieldsis left at its default;SELECT {fields} FROM {table}.
Either table or select_query is required.
Outputs
A list of row dicts — List[Dict[column, value]], courtesy of DictCursor —
or [] when the query matches nothing:
[
{"device_id": 4021, "name": "web-01"},
{"device_id": 4022, "name": "web-02"}
]
Example
{
"host": "db.example.com",
"port": 7706,
"database": "master_dev",
"username": "svc_pf",
"password": "${config.db_password}",
"select_query": "SELECT id, device FROM legend_device WHERE date_edit > NOW() - INTERVAL 1 DAY"
}
Notes
portdefaults to7706, the SL1 MySQL port, not3306.No row limit is applied. A large table comes back in one list and in one step-runner process — page it in the SQL if that matters.
An empty result is
[], not an error, so a downstream step must handle it.