db
Description
Executes a query to a database.
Syntax
db connection=<field> query=[<string> | <field>]
Required Arguments
Parameter | Syntax | Description |
---|---|---|
connection | connection=<field> | Connection name. |
query | query=[<string> | <field>] | SQL query. |
info
If a data retrieval query is executed, the current data is replaced with new data. If a data processing query is executed, the resulting data contains the current data.
Time Stamps
A database query can include the {{_earliest}}
or {{_latest}}
placeholders, which will be replaced with the earliest
or latest
values from the source
command.
Query Examples
Fetching data from a database configured with the connection name mysql
:
Example #1
db connection=mysql query="SELECT * FROM user_info.user;"
Updating data in a database configured with the connection name mysql
. The result retains the data from the source
command:
Example #2
db connection=mysql query="INSERT INTO user_info.user (name, email) VALUES ('Ivan', 'ivan@mail.ru');"
Executing a command with a saved query. The query stored under the name mysql_query
will be executed:
Example #3
db connection=mysql query=mysql_query
Example of a query to a database with time stamps:
Example #4
"SELECT * FROM user_info.user WHERE date_field >= {{_earliest}};"