Script Development / MySQL
The MySQL connector operation object mainly provides some 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
Parameters for DFF.CONN(...)
are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
connector_id |
str | Required | Connector ID |
database |
str | None |
Specified database |
.query(...)
Executes an SQL statement with the following parameters:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
sql |
str | Required | SQL statement, which may include parameter placeholders.? represents a parameter that needs escaping;?? represents a parameter that does not need escaping |
sql_params |
list | None |
SQL parameters |
Example | |
---|---|
1 2 3 |
|
.non_query(...)
Executes insert, delete, update, etc., SQL statements and returns the number of affected rows. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
sql |
str | Required | SQL statement, which may include parameter placeholders.? represents a parameter that needs escaping;?? represents a parameter that does not need escaping |
sql_params |
list | None |
SQL parameters |
Example | |
---|---|
1 2 3 |
|
Dynamic SQL Statements
Both query(...)
and non_query(...)
use DFF.SQL(...)
internally to construct SQL statements and support building complex dynamic SQL statements.
For example, handling uncertain numbers of values in WHERE IN (...)
, or performing bulk data inserts using INSERT INTO ... VALUES ...
.
For more details, please refer to Script Development / SQL Construction DFF.SQL