# mysql.exec ## Function Execute SQL that does not require a result set to be returned. Ordinary binding is executed once; binds batch configuration will be executed by batch/workers. ## Syntax ```bt mysql(dsn).query(sql).exec() ``` ## Parameters No parameters. ## Return value | Type | Description | | ------ | ------ | | Object | Returns the SQL execution statistics object. | ## Execution result field | Field | Type | Must exist | Description | | ------ | ------ | ------ | ------ | | total | Int | Yes | The number of bound rows processed in this execution. When ordinary `bind()` is executed, it is `1`; when batch `binds()` is executed, it is the number of bound array rows; when there is no bound row, it is `0`. | | rows_affected | Int | Yes | The number of affected rows reported by the database. When batch execution is performed, the value is accumulated for each batch. | | last_insert_id | Int | Yes | The last insert ID reported by the database. When executing in batches, the maximum value returned in each batch is taken. | | batch_count | Int | Yes | The actual number of batches split executed. This is usually `1` for normal execution; `0` without a bound line. | | batch_size | Int | Yes | The batch size for the current query builder configuration. Default value used when `batch()` is not called. | | workers | Int | Yes | The number of concurrent workers configured and normalized by the current query builder. | ## Example ```bt db = mysql('mysql://user:pass@127.0.0.1/test') ret = db.query('insert into user(name) values (?)').bind('BT').exec() result = ret.rows_affected // Example output: 1 echo(result) ``` ## Notes - Normal `bind()` performs default reuse of the MySQL global connection pool grouped by DSN. - `binds()` Batch execution still creates a temporary connection pool according to this `workers()` to avoid the global pool changing the batch concurrency boundary. - Simple INSERT ... VALUES (?, ?) are automatically merged into multi-value inserts. - UPDATE and DELETE will not automatically splice SQL, but will be executed one by one in batches. - Single call subject to `BT_MYSQL_QUERY_TIMEOUT_MS` limit.