diff --git a/.env.example b/.env.example deleted file mode 100644 index faf8954..0000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=DB URL \ No newline at end of file diff --git a/src/db.rs b/src/db.rs index 55e663a..e9503b9 100644 --- a/src/db.rs +++ b/src/db.rs @@ -5,15 +5,18 @@ pub struct Connection { impl Connection { pub async fn create_connection(db_url: &str) -> Result { - println!("\nStart db connection"); + println!("Start db connection..."); let builder = mysql_async::OptsBuilder::from_opts(mysql_async::Opts::from_url(&db_url)?); let pool = mysql_async::Pool::new(builder.ssl_opts(mysql_async::SslOpts::default())); let conn = pool.get_conn().await?; + println!("DB Connection suceesfully establised"); Ok(Self { conn, pool }) } pub async fn close_connection(self) -> Result<(), mysql_async::Error> { + println!("Closing DB Connection..."); drop(self.conn); self.pool.disconnect().await?; + println!("DB Connection succesfully closed"); Ok(()) } } diff --git a/src/excel.rs b/src/excel.rs index 05ca67e..ad0ecde 100644 --- a/src/excel.rs +++ b/src/excel.rs @@ -134,6 +134,7 @@ impl Excel { }); } } + println!("Succesfully parsed {} classes from excel", list_class.len()); Ok(list_class) } } diff --git a/src/repo.rs b/src/repo.rs index 01bd5fe..c999fcf 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -42,7 +42,7 @@ impl ClassRepository { loaded_subject.into_iter().for_each(|subject| { self.subjects.insert(subject.name, subject.id); }); - + println!("Succesfully fetch all subjects from DB"); Ok(()) } @@ -62,7 +62,7 @@ impl ClassRepository { loaded_lecture.into_iter().for_each(|lecture| { self.lecturers.insert(lecture.code, lecture.id); }); - + println!("Succesfully fetch all lecturers from DB"); Ok(()) } @@ -83,7 +83,7 @@ impl ClassRepository { let session_start = session.session_time.split("-").collect::>()[0]; self.sessions.insert(session_start.to_string(), session.id); }); - + println!("Succesfully fetch all sessions from DB"); Ok(()) } @@ -93,6 +93,7 @@ impl ClassRepository { conn: &mut mysql_async::Conn, data: Vec, ) -> Result<(), mysql_async::Error> { + println!("Start insert class to DB..."); conn.query_drop("DELETE FROM Plan").await?; conn.query_drop("DELETE FROM _ClassToPlan").await?; conn.query_drop("DELETE FROM Class").await?; @@ -122,6 +123,7 @@ impl ClassRepository { ); conn.exec_drop(&prepared_stmt, values).await?; } + println!("Succesfully insert {} classes to DB", data.len()); Ok(()) } }