Add a SQLite database backend #265

Merged
wojtek merged 20 commits from 248---replace-json-file-as-a-database-with-sqlite into main 2025-01-12 10:24:53 +01:00
Showing only changes of commit 7b6cb56066 - Show all commits

View File

@ -156,7 +156,7 @@ impl<SDB: for<'conn> ISqlDatabaseBackend<'conn>> IDatabase for SqlDatabase<SDB>
let version = tx let version = tx
.select_database_version()? .select_database_version()?
.ok_or_else(|| LoadError::SerDeError(String::from("missing database version")))?; .ok_or_else(|| Error::SerDeError(String::from("missing database version")))?;
let database = match version.as_str() { let database = match version.as_str() {
V20250103 => { V20250103 => {
@ -164,14 +164,10 @@ impl<SDB: for<'conn> ISqlDatabaseBackend<'conn>> IDatabase for SqlDatabase<SDB>
for artist in coll.iter_mut() { for artist in coll.iter_mut() {
artist.albums.extend(tx.select_artist_albums(&artist.name)?); artist.albums.extend(tx.select_artist_albums(&artist.name)?);
} }
DeserializeDatabase::V20250103(coll) Ok(DeserializeDatabase::V20250103(coll))
} }
s => { s => Err(Error::SerDeError(format!("unknown database version: {s}"))),
return Err(LoadError::SerDeError(format!( }?;
"unknown database version: {s}"
)))
}
};
tx.commit()?; tx.commit()?;
Ok(database.into()) Ok(database.into())