diff --git a/back/data/data.db b/back/data/data.db deleted file mode 100644 index df4b1ba..0000000 Binary files a/back/data/data.db and /dev/null differ diff --git a/back/src/create_db.rs b/back/src/create_db.rs index 60140e1..06e2663 100644 --- a/back/src/create_db.rs +++ b/back/src/create_db.rs @@ -1,9 +1,14 @@ -use sqlite::{Connection, State, Error}; +use sqlite::{Connection, OpenFlags}; pub fn init() -> sqlite::Result<()> { - let conn = Connection::open("./data/data.db")?; + let conn = Connection::open_with_flags( + "./data/data.db", + OpenFlags::new() + .with_create() + .with_read_write() + ); - conn.execute( + conn?.execute( "CREATE TABLE IF NOT EXISTS articles ( id INTEGER PRIMARY KEY, title TEXT NOT NULL, diff --git a/back/src/main.rs b/back/src/main.rs index e090ab8..320c18f 100644 --- a/back/src/main.rs +++ b/back/src/main.rs @@ -1,10 +1,10 @@ +mod create_db; +use create_db::init; + use actix_web::{App, HttpServer, get, Responder, HttpResponse, http::header::ContentType}; use actix_files::Files; use serde_json::json; -use sqlite::{Connection, State, Error}; - -mod create_db; -use create_db::init; +use sqlite::{Connection, State}; #[get("/api/hello")] async fn hello() -> impl Responder { @@ -48,7 +48,7 @@ async fn api() -> impl Responder { #[actix_web::main] async fn main() -> Result<(), std::io::Error> { - init(); + let _ = init(); HttpServer::new(|| { App::new()