Query the database if the requested table already exists.
(&self, name: &str)
| 490 | |
| 491 | /// Query the database if the requested table already exists. |
| 492 | pub async fn table_exists(&self, name: &str) -> Result<bool> { |
| 493 | let query_only = true; |
| 494 | self.call(query_only, move |conn| { |
| 495 | let mut exists = false; |
| 496 | conn.pragma(None, "table_info", name.to_string(), |_row| { |
| 497 | // will only be executed if the info was found |
| 498 | exists = true; |
| 499 | Ok(()) |
| 500 | })?; |
| 501 | |
| 502 | Ok(exists) |
| 503 | }) |
| 504 | .await |
| 505 | } |
| 506 | |
| 507 | /// Check if a column exists in a given table. |
| 508 | pub async fn col_exists(&self, table_name: &str, col_name: &str) -> Result<bool> { |