Script Development / MySQL
The MySQL connector operation object primarily provides methods for operating MySQL. This connector supports the following databases:
- MariaDB
- Percona Server for MySQL
- Alibaba Cloud PolarDB MySQL
- Alibaba Cloud OceanBase
- Alibaba Cloud AnalyticDB (ADB) MySQL Edition
DFF.CONN(...) parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
connector_id |
str | Required | Connector ID |
database |
str | None |
Specified database |
.query(...)
Executes an SQL statement. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
sql |
str | Required | SQL statement, which can contain parameter placeholders.? indicates a parameter that needs escaping;?? indicates a parameter that does not need escaping |
sql_params |
list | None |
SQL parameters |
| Example | |
|---|---|
1 2 3 | |
.non_query(...)
Executes SQL statements such as INSERT, DELETE, UPDATE, etc., and returns the number of affected rows. Parameters are as follows:
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
sql |
str | Required | SQL statement, which can contain parameter placeholders.? indicates a parameter that needs escaping;?? indicates a parameter that does not need escaping |
sql_params |
list | None |
SQL parameters |
| Example | |
|---|---|
1 2 3 | |
Dynamic SQL Statements
query(...) and non_query(...) internally use DFF.SQL(...) to construct SQL statements and support constructing complex dynamic SQL statements.
Such as WHERE IN (...) with an uncertain number of values, or INSERT INTO ... VALUES ... for batch data insertion, etc.
For details, please refer to Script Development / SQL Construction DFF.SQL