(path: String)
| 25 | |
| 26 | impl Database { |
| 27 | pub async fn create(path: String) -> Result<Self, DbErr> { |
| 28 | AsyncFile::new_ow(path.parse().expect("UrlErr")) // overwrite the file |
| 29 | .await |
| 30 | .expect("File System Error"); |
| 31 | let mut opt = ConnectOptions::new(format!("sqlite://{path}?mode=rw")); |
| 32 | opt.max_connections(1).sqlx_logging(false); |
| 33 | let db = SeaDatabase::connect(opt).await?; |
| 34 | create_tables(&db).await?; |
| 35 | Ok(Self { path, db: Some(db) }) |
| 36 | } |
| 37 | |
| 38 | pub async fn reopen(&mut self) -> Result<(), DbErr> { |
| 39 | // Close existing db, if any |
nothing calls this directly
no test coverage detected