Execute the function inside a transaction. `query_only` - Whether the function only executes read statements (queries) and can be run in parallel with other transactions. NB: Creating and modifying temporary tables are also allowed with `query_only`, temporary tables aren't visible in other connections, but you need to pass `PRAGMA query_only=0;` to SQLite before that: ```text pragma_update(None,
(&self, query_only: bool, callback: G)
| 466 | /// If the function returns an error, the transaction will be rolled back. If it does not return |
| 467 | /// an error, the transaction will be committed. |
| 468 | pub async fn transaction_ex<G, H>(&self, query_only: bool, callback: G) -> Result<H> |
| 469 | where |
| 470 | H: Send + 'static, |
| 471 | G: Send + FnOnce(&mut rusqlite::Transaction<'_>) -> Result<H>, |
| 472 | { |
| 473 | self.call(query_only, move |conn| { |
| 474 | let mut transaction = conn.transaction()?; |
| 475 | let ret = callback(&mut transaction); |
| 476 | |
| 477 | match ret { |
| 478 | Ok(ret) => { |
| 479 | transaction.commit()?; |
| 480 | Ok(ret) |
| 481 | } |
| 482 | Err(err) => { |
| 483 | transaction.rollback()?; |
| 484 | Err(err) |
| 485 | } |
| 486 | } |
| 487 | }) |
| 488 | .await |
| 489 | } |
| 490 | |
| 491 | /// Query the database if the requested table already exists. |
| 492 | pub async fn table_exists(&self, name: &str) -> Result<bool> { |
no test coverage detected