| 62 | } |
| 63 | |
| 64 | bool DB::existDBUnsafe(SQLite::Database* db, String name) { |
| 65 | bool existed = false; |
| 66 | if (!name.empty()) { |
| 67 | try { |
| 68 | SQLite::Statement statement(*db, fmt::format("SELECT EXISTS(SELECT 1 FROM pragma_database_list WHERE name = ?)", name.toString())); |
| 69 | statement.bind(1, name.toString()); |
| 70 | int result = 0; |
| 71 | if (statement.executeStep()) { |
| 72 | result = statement.getColumn(0); |
| 73 | } |
| 74 | existed = result == 0 ? false : true; |
| 75 | } catch (std::exception& e) { |
| 76 | Warn("failed to execute DB query: {}", e.what()); |
| 77 | } |
| 78 | } |
| 79 | return existed; |
| 80 | } |
| 81 | |
| 82 | bool DB::existDB(String name) const { |
| 83 | bool existed = false; |