Skip to content

Commit

Permalink
Fix building with a clean project
Browse files Browse the repository at this point in the history
  • Loading branch information
FakeMichau committed Aug 23, 2023
1 parent 66b76b7 commit 83b9575
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL="sqlite:database.compile.db3"
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/target
.vscode/*
*.db3
database.db3
tokens
Settings.toml
.env
Binary file added database.compile.db3
Binary file not shown.
7 changes: 6 additions & 1 deletion lma_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ pub use api::{
};
pub use lib_mal::*;
use serde::{Deserialize, Serialize};
use sqlx::sqlite::SqliteConnectOptions;
use sqlx::{Sqlite, SqlitePool};
use std::cmp::Ordering;
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::str::FromStr;

pub struct AnimeList<T: Service + Send + Sync> {
db_connection: sqlx::Pool<Sqlite>,
Expand Down Expand Up @@ -348,7 +350,10 @@ pub async fn create<T: Service + Send + Sync>(
) -> Result<AnimeList<T>, String> {
let path = data_path.join("database.db3");
let url = format!("sqlite:{}", path.to_string_lossy());
let db_pool = SqlitePool::connect(&url)
let options = SqliteConnectOptions::from_str(&url)
.map_err(|err| format!("Can't create db options {err}"))?
.create_if_missing(true);
let db_pool = SqlitePool::connect_with(options)
.await
.map_err(|err| format!("Can't create db connection {err}"))?;
let result = sqlx::query!("
Expand Down

0 comments on commit 83b9575

Please sign in to comment.