Got all cards out from db

This commit is contained in:
2025-08-16 03:59:24 +01:00
parent ff4c58113f
commit 72fa35d41a
3 changed files with 21 additions and 7 deletions

View File

@@ -26,6 +26,18 @@ CREATE TABLE cards (
.to_string()
}
pub fn get_all_card_names() -> Vec<String> {
let sqlite_file = get_local_data_sqlite_file();
let conn = rusqlite::Connection::open(sqlite_file).unwrap();
let mut stmt = conn.prepare("SELECT name FROM cards;").unwrap();
let mut rows = stmt.query([]).unwrap();
let mut card_names = Vec::new();
while let Some(row) = rows.next().unwrap() {
card_names.push(row.get(0).unwrap());
}
card_names
}
pub fn update_db_with_file(file: PathBuf) -> bool {
let ac = fs::read_to_string(file).unwrap();
let ac: Vec<ScryfallCard> = serde_json::from_str(&ac).unwrap();